使用facebook android sdk发布到朋友墙时,无法发布给用户墙错误

时间:2014-02-11 06:58:04

标签: android facebook-android-sdk

我正在尝试使用facebook android sdk(3.6version)发布给我的朋友墙。

我使用WebDialog类发布.Below是我的代码

 private void publishFeedDialog(String friend_uid) {



           try{
                Session mCurrentSession = Session.getActiveSession();

                SessionTracker mSessionTracker = new SessionTracker(
                        MainActivity.this, new StatusCallback() {
                            public void call(Session session, SessionState state,
                                    Exception exception) {
                            }
                        }, null, false);
                String applicationId = Utility
                .getMetadataApplicationId(getBaseContext());
                mCurrentSession = mSessionTracker.getSession();

                if (mCurrentSession == null
                        || mCurrentSession.getState().isClosed()) {
                    mSessionTracker.setSession(null);
                    Session session = new Session.Builder(getBaseContext())
                    .setApplicationId(applicationId).build();
                    Session.setActiveSession(session);
                    mCurrentSession = session;
                }

                if (!mCurrentSession.isOpened()) {
                    Session.OpenRequest openRequest = null;
                    openRequest = new Session.OpenRequest(
                           MainActivity.this);

                    if (openRequest != null) {
                        openRequest
                        .setDefaultAudience(SessionDefaultAudience.FRIENDS);
                        openRequest.setPermissions(Arrays.asList("email", "publish_actions"));
                        openRequest
                        .setLoginBehavior(SessionLoginBehavior.SUPPRESS_SSO);



                        mCurrentSession.openForPublish(openRequest);
                    }
                }



                if (strCurrentuser != null && friend_uid != null ) {

                    final Activity activity = this;
                    Bundle params = new Bundle();
                    //This is what you need to post to a friend's wall
                    params.putString("from", "" + strCurrentuser);
                    params.putString("to", friend_uid);
                    //up to this
                    params.putString("name", "Facebook SDK for Android");
                    params.putString("caption", "Build great social apps and get more installs.");
                    params.putString("description", "The Facebook SDK for Android makes it easier and faster to develop Facebook integrated Android apps.");
                    params.putString("link", "https://developers.facebook.com/android");
                    params.putString("picture", "https://raw.github.com/fbsamples/ios-3.x-howtos/master/Images/iossdk_logo.png");
                    WebDialog feedDialog = (new WebDialog.FeedDialogBuilder(this, mCurrentSession, params))
                            .setOnCompleteListener(new OnCompleteListener() {

                            @Override
                            public void onComplete(Bundle values, FacebookException error) {
                                if (error == null) {
                                    // When the story is posted, echo the success
                                    // and the post Id.
                                    final String postId = values.getString("post_id");
                                    if (postId != null) {
                                        Toast.makeText(activity,
                                            "Posted story, id: "+postId,
                                            Toast.LENGTH_SHORT).show();
                                    } else {
                                        // User clicked the Cancel button
                                        Toast.makeText(activity, 
                                            "Publish cancelled", 
                                            Toast.LENGTH_SHORT).show();
                                    }
                                } else if (error instanceof FacebookOperationCanceledException) {
                                    // User clicked the "x" button
                                    Toast.makeText(activity, 
                                        "Publish cancelled", 
                                        Toast.LENGTH_SHORT).show();
                                } else {
                                    // Generic, ex: network error
                                    Toast.makeText(activity, 
                                        "Error posting story", 
                                        Toast.LENGTH_SHORT).show();
                                }
                            }



                        }).build();
                    feedDialog.show();
                }
        }catch(Exception e)
        {
            Log.d("Error", ""+e.toString());
        }
         }

But I am getting the error which I show in below picture

enter image description here

我也试过在Android sdk的Facebook类中使用dialog(),但这也向我显示了与上面给出的相同的对话框。 但我相信我拥有所有权限。

以下是我的权限:

[photo_upload,publish_stream,video_upload,installed,publish_checkins,publish_actions,share_item,user_friends,email,user_photos,public_profile,status_update,create_note,basic_info]

Bundle params = new Bundle();
            params.putString("to", "xxxxxxx1890xxxxxx");

            mFacebook.dialog(MainActivity.this, "feed", params,new DialogListener(
                    ) {

                @Override
                public void onFacebookError(FacebookError e) {
                    // TODO Auto-generated method stub
                    e.printStackTrace();
                }

                @Override
                public void onError(DialogError e) {
                    // TODO Auto-generated method stub
                    e.printStackTrace();
                }

                @Override
                public void onComplete(Bundle values) {
                    // TODO Auto-generated method stub
                    Log.e("values",""+values);
                }

                @Override
                public void onCancel() {
                    // TODO Auto-generated method stub

                }
            } );

        }
    });

任何人都可以建议我如何解决这个错误?

0 个答案:

没有答案