0

I use this code to share image and link on 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);
}

This code worked well but, I need to set the message. How can I set message?

  • Possible duplicate of [Android share intent for facebook- share text AND link](http://stackoverflow.com/questions/8771333/android-share-intent-for-facebook-share-text-and-link) – klimat May 17 '16 at 20:45
  • By using message you mean the `contentDescription`? – Iulian Popescu May 17 '16 at 22:04
  • Who wrote the title and description? – WizKid May 17 '16 at 22:11
  • I want to put a text on comment above of link. Like when user type a comment when post a link. The contentDescription only a text of information a link. I need to put a comment like a user. In iOS I use it: FBSDKGraphRequest But Android don't have this option – Alexandre C. do Carmo May 18 '16 at 01:06
  • The message part of any share has to be a 100% user generated, basically meaning the user has to type it in. Your app is __not allowed__ to pre-fill the message, or actually specify it itself when making a post via API. You should go read [Platform Policy](https://developers.facebook.com/policy/) first of all. (2.3 is the most relevant point here.) – CBroe May 18 '16 at 08:58
  • When I use Instagram, choose a picture and put a legend, I choose facebook to share. In facebook the legend instagram was added in comment and below added the picture. I created it in iOS, and I use: FBSDKGraphRequest This code receive a array that one of the options is message, that work like instagram. There must be a way to use this option in android – Alexandre C. do Carmo May 18 '16 at 11:47

1 Answers1

0

Problem solved. I use 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();

This is the documentation: Documentation