Reputation: 7586
I've been succeeded uploading a photo to Facebook via my Android app, which exists in the album created for my app, but the photo needs to be approved manually by the user, and Facebook said:
Would you like to add these photos to your album?
The photos below were uploaded from another application, you'll need to approve them.
It looks like this on Facebook:
By the way, I've added the user_photos
permission. And here is the code for uploading:
public void uploadToFB(Uri photo){
Session session = Session.getActiveSession();
Bundle bundle = new Bundle();
bundle.putString("url", "http://6269-9001.zippykid.netdna-cdn.com/wp-content/uploads/2013/09/Cute-Dog-Wallpaper-Pictures.jpg");
new Request(
session,
"/me/photos",
bundle,
HttpMethod.POST,
new Request.Callback() {
@Override
public void onCompleted(Response response) {
dialog.dismiss();
}
}
).executeAsync();
}
In the MainActivity:
@Override
protected void onResumeFragments() {
super.onResumeFragments();
Session session = Session.getActiveSession();
if (session != null && session.isOpened()) {
startActivity(new Intent(this, LoggedMainActivity.class));
} else {
showLoginFragment();
}
}
private void showLoginFragment(){
LoginFragment login=new LoginFragment();
getSupportFragmentManager()
.beginTransaction()
.add(android.R.id.content, login)
.commit();
}
And this is the LoginFragment:
public class LoginFragment extends Fragment {
private LoginButton authButton;
@Override
public View onCreateView(LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.login_fragment,
container, false);
authButton=(LoginButton)view.findViewById(R.id.login_button);
authButton.setReadPermissions(Arrays.asList("user_photos","publish_stream","read_stream"));
return view;
}
}
Upvotes: 1
Views: 1033
Reputation: 6714
You are missing the publish_stream
permission on Your Facebook Login Widget
Here is a demonstration of how to add that permission:
/*LoginButton authButton = (LoginButton) findViewById(R.id.YOUR_ID);
authButton.setReadPermissions(Arrays.asList("user_photos"));
authButton.setPublishPermissions(Arrays.asList("publish_stream","read_stream"));*/
Just Add these permissions to your Login Widget and everything should work fine.
Edit:
Setting up Read and Publish Permissions together :
Get Read and Publish Permissions in one request
I hope this helps.
Upvotes: 1