通过Android上传的照片未在Facebook上获得批准

时间:2014-01-26 13:07:10

标签: android facebook

我已成功通过我的Android应用程序将照片上传到Facebook,该应用程序存在于为我的应用程序创建的相册中,但照片需要由用户手动批准,并且Facebook说:

Would you like to add these photos to your album?
The photos below were uploaded from another application, you'll need to approve them.

在Facebook上看起来像这样:

enter image description here

顺便说一下,我添加了user_photos权限。以下是上传代码:

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();

}

在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();
}

这是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;
}

}

1 个答案:

答案 0 :(得分:1)

您遗漏了publish_stream

Facebook Login Widget权限

以下是如何添加该权限的演示:

/*LoginButton authButton = (LoginButton) findViewById(R.id.YOUR_ID);
authButton.setReadPermissions(Arrays.asList("user_photos"));
authButton.setPublishPermissions(Arrays.asList("publish_stream","read_stream"));*/

只需将这些权限添加到您的登录窗口小部件,一切都应该正常工作。

编辑:
Setting up Read and Publish Permissions together :
Get Read and Publish Permissions in one request

我希望这会有所帮助。