Facebook ShareLinkContent不使用消息

时间:2016-05-17 20:39:00

标签: android facebook

我使用此代码在Facebook上分享图片和链接:

private void shareLinkToFacebook(int idBeer){
    ShareLinkContent content = new ShareLinkContent.Builder()
            .setImageUrl(Uri.parse("https: link to image"))
            .setContentTitle("Beer")
            .setContentDescription(
                    "Test Comment")
            .setContentUrl(Uri.parse("http://alexandreccarmo.com"))
            .build();

    ShareApi.share(content, null);
}

此代码运行良好,但我需要设置消息。我该如何设置信息?

1 个答案:

答案 0 :(得分:0)

问题解决了。我使用Open graph。

Bundle params = new Bundle();
params.putString("message", "This is a test message");
params.putString("link", "http://alexandreccarmo.com");
    params.putString("picture", "link to picture");
    params.putString("name", "Test name");
    params.putString("description", "Teste Description");
    params.putString("caption", "Caption");
    /* make the API call */
   new GraphRequest(
     AccessToken.getCurrentAccessToken(),
       "/me/feed",
        params,
        HttpMethod.POST,
    new GraphRequest.Callback() {
     public void onCompleted(GraphResponse response) {
        /* handle the result */
     }
 }
 ).executeAsync();

这是文档: Documentation