I'm writing an android app and I would like to offer the user to do a "fb like"
to some given facebook pages/images/post
how can I do this?
I have tried using plain Http Post, but it returns all kind of errors.
So I think using Graph API will be neater. no?
public class LikeFbPostAsyncTask extends AsyncTask<String, Void, Void> {
ImageButton mLockImage;
Response fbServerResponse;
public LikeFbPostAsyncTask(ImageButton lockImage) {
mLockImage = lockImage;
}
@Override
protected void onPreExecute() {
Log.i("LikeFbPostAsyncTask", "Starting web task...");
}
@Override
protected Void doInBackground(String... fbPostId) {
Request likeRequest = new Request(Session.getActiveSession(),
fbPostId[0] + "/likes", null, HttpMethod.POST,
new Request.Callback() {
// here is non-ui thread
@Override
public void onCompleted(final Response response) {
Log.i(TAG, response.toString());
fbServerResponse = response;
}
});
Request.executeBatchAndWait(likeRequest);
return null;
}
In addition I'm not sure I'm using a proper "post id".
I haven't seen a good example outside nor in the official documentation.