(#200)响应用户尚未授权应用程序执行此操作

时间:2014-07-26 10:55:26

标签: android facebook

我在我的应用中实施了facebook。登录没有问题通过Facebook设法得到它的响应。当尝试发布错误状态如下:我尝试了许多方式都没有工作。请帮我。

 public class main extends Activity{
        static Session session;
        Activity aty;
        Context context;
        protected static final List<String> PERMISSIONS = Arrays.asList("publish_actions");
        protected boolean pendingPublishReauthorization = false;

    private FacebookloginDelegate delegate;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    setContentView(R.layout.main);


    publishFeedDialog();


    }



    public void loginWithFacebook() {
        // start Facebook Login
        Session.openActiveSession(this, true, new Session.StatusCallback() {

            @Override
            public void call(Session session, SessionState state, Exception exception) {
                // TODO Auto-generated method stub
                if (session != null && session.isOpened()) {



                      Request.newMeRequest(session, new Request.GraphUserCallback() {

                          // callback after Graph API response with user object
                          @Override
                          public void onCompleted(GraphUser user, Response response) {
                            if (user != null) {
                                 if (delegate!=null) 
                                     delegate.onCompletedProgress(user, response);
//                               Toast.makeText(activity, "Sharing to Facebook", Toast.LENGTH_LONG).show();
//                                  publishFeedDialog(activity, fl);
                                 publishFeedDialog();
                            }
                          }
                        }).executeAsync();
             }
            }
        });
    }

    @Override
      public void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
          Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
      }
//  
    public void setDelegate(FacebookloginDelegate delegate_)
    {
        delegate = delegate_;
    }

    protected boolean isSubsetOf(Collection<String> subset, Collection<String> superset) {
        for (String string : subset) {
            if (!superset.contains(string)) {
                return false;
            }
        }
        return true;
    }

    public static abstract class FacebookloginDelegate {
        protected void onCompletedProgress(GraphUser user,
                Response response) {}
    }

    public void publishFeedDialog() 
    {
        Session session = Session.getActiveSession();

        //if session is not empty and it is opened
        if (session != null && session.isOpened()){

            postOnWall();

        }
        else
        {
            // login with facebook if no session is available
            loginWithFacebook();
        }
    }  




    public void postOnWall() {
        Bundle params = new Bundle();
        params.putString("caption", "My Caption");
        params.putString("description", "description here");
        params.putString("picture", "http://test.com");
        params.putString("name", "name string");
        params.putString("message", "my message here");




        session = Session.getActiveSession();

        if(session != null && session.isOpened()){          
            // Check for publish permissions
            if(!session.getPermissions().contains("publish_actions"))   {           
                session.requestNewPublishPermissions(new Session.NewPermissionsRequest(this, PERMISSIONS));
                Log.d("FBAUTOPOST","FBAUTOPOST");
            }

            Request postToWall = new Request(session,"me/feed", params, HttpMethod.POST, new Request.Callback() {

                @Override
                public void onCompleted(Response response) {
                    // TODO Auto-generated method stub
                    Log.i("FB AutoPost:", "FBAUTOPOST" + response.toString());
                    Toast.makeText(main.this, "Content post successfully ", Toast.LENGTH_LONG).show();
                    //session.close();
                }
            });
            RequestAsyncTask task = new RequestAsyncTask(postToWall);
            task.execute(); 
        }

    }

错误消息:

07-26 18:42:02.705: I/FB AutoPost:(4348): FBAUTOPOST{Response:  responseCode: 403, graphObject: null, error: {HttpStatus: 403, errorCode: 200, errorType: OAuthException, errorMessage: (#200) The user hasn't authorized the application to perform this action}, isFromCache:false}

此错误代码在Facebook发布回复后显示。我在我的string.xml中添加了app_id。谢谢你提前。

1 个答案:

答案 0 :(得分:0)

大多数权限需要获得Facebook批准才能将其用于用户。未经批准,这些权限仅适用于App Admins。查看更改日志:https://developers.facebook.com/docs/apps/changelog

  

申请超过public_profile,电子邮件和user_friends权限的应用必须经过Facebook审核,然后才能向用户请求这些权限

审核指南:https://developers.facebook.com/docs/apps/review