I need to post a Bitmap to Facebook wall along with a message and url link.
According to https://developers.facebook.com/docs/reference/api/user/#photos, there are 4 parameters to add a photo to Facebook album:
source, message, place, no_story.
However, I was recommend to use a code like this:
Bitmap bm = ...;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bm.compress(CompressFormat.JPEG, 100, baos);
final byte[] data = baos.toByteArray();
Bundle postParams = new Bundle();
postParams.putByteArray("photo", data);
postParams.putString("message", "My message here");
postParams.putString("link", "http://www.google.com");
Request request = new Request(session, "me/photos", postParams, HttpMethod.POST, callback);
RequestAsyncTask task = new RequestAsyncTask(request);
task.execute();
… and this code works fine except it does not show the link (“http://www.google.com”) on the wall.
I have three questions:
-
Why does
postParams.putByteArray("photo", data)work? There’s nophotoparameter according to documentation (see above). -
If it is impossible to use
linkparameter, how does SLComposeViewController class (http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Reference/SLComposeViewController_Class/Reference/Reference.html) work? It has- (BOOL)addURL:(NSURL *)urlmethod. -
If it is possible to use
linkparameter, why doesn’t it work?
Okay, I found answers to questions (2) and (3). It appeared to be very simple: do not use
link, just append it tomessage:As for my question (1), it is still unclear for me: why does
postParams.putByteArray("photo", data);work fine instead ofpostParams.putByteArray("source", data);? The documentation say nothing aboutphotoparameter.