SimonSays
SimonSays

Reputation: 10977

Post photo to Facebook parameters

I am posting a photo to FB using the new FB Android SDK 3.0. I am now looking for a way to set some more parameters than just the image itself and a simple text. I tried tons of different parameters, but non of them seem to do something.

What i would like to do is to add a link, an icon and, if somehow possible, a custom link item next to the Like and Comment links.

Here is an example of the icon and the custom link item from twitter:

enter image description here

And this is the code that I am currently using:

    byte[] data = get binary image data;

    Bundle postParams = new Bundle();
    postParams.putString("name", "Image text");
    postParams.putByteArray("picture", data);

    // All these parameters do nothing...
    postParams.putString("icon", "http://www.myimage.com/image.png");
    postParams.putString("message", "XXX");
    postParams.putString("caption", "Build great social apps and get more installs.");
    postParams.putString("description", "The Facebook SDK for Android makes it easier and faster to develop Facebook integrated Android apps.");
    postParams.putString("link", "https://developers.facebook.com/android");

    Request request = new Request(Session.getActiveSession(), "me/photos", postParams, HttpMethod.POST);
    Response r = request.executeAndWait();

The post looks like this:

enter image description here

Upvotes: 1

Views: 2937

Answers (1)

Stéphane Bruckert
Stéphane Bruckert

Reputation: 22973

1. Adding the icon

You can manage icons from your app's dashboard: https://developers.facebook.com/apps/APP_ID/appdetails

2. Adding an action link

What you can a "custom link" is in fact an "action".

The "action" you've seen on the Twitter's post has been done using the actions array from the Post table:

A list of available actions on the post (including commenting, liking, and an optional app-specified action)

So, your only choice if you really want to add this action near Like · Comment is to create a Post into the Feed and not a Photo.

Here is an a priori working code:

postParams.putString("message", "XXX");
postParams.putString("caption", "developers.facebook.com");
postParams.putString("description", "A tool to help you learn and browse the Facebook Graph API.");
postParams.putString("actions", "[{
       'name':'Test a simple Graph API call!',
       'link':'https://developers.facebook.com/tools/explorer?method=GET&path=me'
       /* ^ This link must direct to the application's connect or canvas URL. 
          You'll get an error otherwise. */
    }]"
);
postParams.putString("type", "photo");
postParams.putString("link", "https://developers.facebook.com/tools/explorer/");
postParams.putString("picture", "http://blog.programmableweb.com/wp-content/ishot-44.png");

Request request = new Request(Session.getActiveSession(), "me/feed", postParams, HttpMethod.POST);

3. Test in the Graph API Explorer

Test in the Graph API Explorer

4. Timeline preview

Timeline preview

Upvotes: 2

Related Questions