0

通过 facebook 分享我的应用程序时,它运行良好,但在帖子上显示“只有我”。我希望所有朋友都可以看到该帖子。下面是我正在使用的代码片段:

 private static final List<String> PERMISSIONS = Arrays.asList("publish_actions");

在创建方法中:

 com.facebook.Settings.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS);

     com.facebook.Session session = com.facebook.Session.getActiveSession();
        if (session == null) {
            if (savedInstanceState != null) {
                session = com.facebook.Session.restoreSession(this, null, statusCallback, savedInstanceState);
            }
            if (session == null) {
                session = new com.facebook.Session(this);
            }
            com.facebook.Session.setActiveSession(session);
            if (session.getState().equals(SessionState.CREATED_TOKEN_LOADED)) {
                session.openForRead(new com.facebook.Session.OpenRequest(this).setCallback(statusCallback));

                session.openForPublish(new Session.OpenRequest(this)
                .setCallback(statusCallback)
                .setLoginBehavior(SessionLoginBehavior.SUPPRESS_SSO)
                .setPermissions(Arrays.asList("publish_actions")));


            }

我正在使用愚蠢的代码来发布故事

private void uploadStoryUsingFacebook() {

//  Toast.makeText(HomeScreenActivity.this, "NOw we can post story !!!",2000).show();
      // Check for publish permissions    
    Session session = Session.getActiveSession();
    List<String> permissions = session.getPermissions();
    if (!isSubsetOf(PERMISSIONS, permissions)) {
        pendingPublishReauthorization = true;
        Session.NewPermissionsRequest newPermissionsRequest = new Session
                .NewPermissionsRequest(this, PERMISSIONS);
    session.requestNewPublishPermissions(newPermissionsRequest);
        return;
    }

     Bundle params = new Bundle();
        params.putString("name", "");
        params.putString("link", "some link");
        params.putString("picture", "some picture");



        FeedDialogBuilder builder = new FeedDialogBuilder(HomeScreenActivity.this, Session.getActiveSession(), params);

        builder.setOnCompleteListener(new OnCompleteListener() {

            @Override
            public void onComplete(Bundle values, FacebookException error) {


                if (error != null) {

                }

                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(HomeScreenActivity.this,"Posted story, id: "+postId,Toast.LENGTH_SHORT).show();
                    } else {
                        // User clicked the Cancel button
                        Toast.makeText(HomeScreenActivity.this, "Publish cancelled",Toast.LENGTH_SHORT).show();
                    }
                } else if (error instanceof FacebookOperationCanceledException) {
                    // User clicked the "x" button
                    Toast.makeText(HomeScreenActivity.this.getApplicationContext(), "Publish cancelled", Toast.LENGTH_SHORT).show();
                } else {
                    // Generic, ex: network error
                    Toast.makeText(HomeScreenActivity.this.getApplicationContext(), "Error posting story",Toast.LENGTH_SHORT).show();
                }


            }
        });

        builder.build().show();


}

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

}

谁能指导我解决这个问题?

4

1 回答 1

0

试试这个->

  1. 从您的 fb 帐户中删除您的应用程序(点击此链接
  2. 现在清除设备上的所有数据。
  3. 尝试从您的应用程序再次发布,现在它会询问您的权限,同时您可以看到底部有一个用于帖子可见性的下拉菜单,将其更改为公开。
于 2013-05-10T18:07:12.627 回答