Is it possible to "Like" a "fan page" using the Facebook SDK?
Asked Answered
D

3

10

I am trying to let users "like" a Facebook fan page from within an Android app. I am able to successfully "like" objects such as wall comments using code like this,

mFacebook = new Facebook(APP_ID);   
SessionStore.restore(mFacebook, this);        

mAsyncRunner = new AsyncFacebookRunner(mFacebook);
Bundle parameters = new Bundle();
mAsyncRunner.request(COMMENT_ID + "/likes", parameters, "POST", new MyRequestListener(), "");

However, if I put in a page id rather than a comment id, I get this error message in the Facebook response,

Response: {"error":{"type":"OAuthException","message":"(#200) App does not have permission to make this call"}}

I am obtaining both the "publish_stream" and "offline_access" publishing permissions at login, and they are given to the Facebook object with SessionStore.restore().

1) Does Facebook let apps "like" fan pages?

2) If so, any ideas on what I am doing wrong?

Thanks, Matt

Decrypt answered 12/3, 2011 at 21:21 Comment(2)
You have the two stream permissions that are required. Is the fan page publicly available? I have similar logic in Python that works just fine for liking pages, unless the page is not public, in which case I get a permission error.Lefton
That's a good thought. Yes, the Facebook page is public. And it is helpful to know "liking" a page is possible from a third-party application. I think the question now is whether there is a limitation in the Facebook Android SDK, or whether I am simply coding improperly. You don't happen to be using Python within an Android app?Decrypt
S
10

The Facebook documentation for Pages has been updated and is current (see https://developers.facebook.com/docs/reference/api/page/). You cannot like a Page via the Graph API, even though you can read the like count information.

Stipulation answered 19/7, 2011 at 4:48 Comment(0)
D
7

As other answers say, it is not possible to 'like' pages via the Graph API.

The confusion in this topic comes from the API documentation, where is says You can comment on or like any object that has a /comments or /likes connection (The key term here is connection)

Going a little deeper: Any object (in this case a Page), has a number of Fields and Connections. Fields are basically used to access the object information and Connections are used to perform operations in that object.

In sum, a Page doesn't have a /likes Connection, but it has a /likes Field, reason why we can get the number of likes of a given page, but we cannot like a page.

Defaulter answered 5/1, 2012 at 13:44 Comment(0)
W
3

Unfortunately, as far as I know so far, you can't like Pages via the API. You can render a Like button via a web view, but I think you're out of luck here at least. You can (as you note) like comments and posts, but pages still require direct user interaction.

Wildebeest answered 17/4, 2011 at 21:36 Comment(3)
DoryEx, have you seen this formally documented somewhere? I think you are likely right, but I have not seen this stated or implied anywhere in the Facebook Graph API documentation. In fact the documenation seems to imply you should be able to like a page. "Like the given object if it has a /likes connection" I am hesitant to accept this as the final answer yet. I am curious if anyone knows if it is possible to like a page from an iPhone app.Decrypt
Unfortunately no, I haven't seen it properly described - this is just from a lot of hunting and testing. Hope it helps!Wildebeest
you can try this github.com/crowjdh/android-facebook-like-button-integrationGyrus

© 2022 - 2024 — McMap. All rights reserved.