【问题标题】:Posting to facebook fan page and to the user's wall in the same time. Android同时发布到 facebook 粉丝页面和用户的墙上。安卓
【发布时间】:2012-05-02 11:03:36
【问题描述】:

我的 android 应用程序允许用户在 Facebook 上分享一些有趣的文本片段。

在用户的墙上分享可以正常工作,并使用本教程实现: http://www.integratingstuff.com/2010/10/14/integrating-facebook-into-an-android-application/

我还有一个我的应用程序的 facebook 粉丝页面,我想在该页面上合并所有此类个人共享。 这样当一些用户在他们的墙上分享文本时,程序也会在 facebook 粉丝页面上发布,这样如果有人对讨论感兴趣,他们可以喜欢粉丝页面并订阅其他用户制作的所有 cmets。

我的问题是我可以在用户的​​墙上发布或在粉丝页面上发布。 我怎样才能同时做到这两点?

public void postToWall(){
    Bundle parameters = new Bundle();
        parameters.putString("message", this.messageToPost);
        parameters.putString("description", this.messageDesc);
        parameters.putString("link", this.messageLink);
 // parameters.putString("target_id", FAN_PAGE_ID);

        try {
                facebook.request("me");
             //   String response = facebook.request("me/feed", parameters, "POST");
                String response = facebook.request(FAN_PAGE_ID+"/feed", parameters, "POST");
                Log.d("Tests", "got response: " + response);
                if (response == null || response.equals("") ||
                response.equals("false")) {
                    showToast("Blank response.");
        }
        else {
            showToast("Message posted to your facebook wall!");
        }
        finish();
    } catch (Exception e) {
        showToast("Failed to post to wall!");
        e.printStackTrace();
        finish();
    }
}

此行发布到用户的墙

    String response = facebook.request("me/feed", parameters, "POST");

这个是粉丝页面

            String response = facebook.request(FAN_PAGE_ID+"/feed", parameters, "POST");

我已为我的应用设置了使用此帖子在粉丝页面上发布的权限 Simple example to post to a Facebook fan page via PHP?

【问题讨论】:

    标签: facebook facebook-android-sdk


    【解决方案1】:

    我遇到了同样的问题,我只是通过两个 asyncfacebookrunner 类完成了请求。所以基本上它们是同时发生的。

    private AsyncFacebookRunner mAsyncFbRunner; 
    private AsyncFacebookRunner mAsyncFbRunner2;
    
    public void postToWall() {
    
        boolean success = true;
    
        Bundle params = new Bundle();
    
        //this is for posting on the walls
    
        parameters.putString("message", this.messageToPost);
        parameters.putString("description", this.messageDesc);
        parameters.putString("link", this.messageLink);
    
        mAsyncFbRunner.request("me/feed", params,"POST", new WallPostListener(), success);
        mAsyncFbRunner2.request(FAN_PAGE_ID+/"feed", params,"POST", new WallPostListener(), success);
    
    }
    

    【讨论】:

      猜你喜欢
      • 2010-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-18
      • 2011-12-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多