0

I have my android application allowing user to share interesting fragments of some texts on the Facebook.

Sharing on the user's wall works fine and is implemented using this tutorial: http://www.integratingstuff.com/2010/10/14/integrating-facebook-into-an-android-application/

I also have a facebook fan page of my application and I would like to consolidate all such individual shares on that page. So that when some user shares text on their wall the program would also publish this on facebook fan page, so that if someone is interested in the discussion they could like the fan page and subscribe to all the comments other users make.

My problem is that I can either publish on user's wall or publish on fan page. How can I do both at the same time?

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

This line publishes to user's wall

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

And this one to fans page

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

I have set up permissions for my app to publish on the fan page using this post Simple example to post to a Facebook fan page via PHP?

4

1 回答 1

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

}
于 2012-08-26T19:32:58.697 回答