"Like" a Page using the Facebook Graph API, Objective C
Asked Answered
E

5

5

I'm trying to allow the user of my iOS app to "Like" a page using the following code:

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"access_token",[[NSUserDefaults standardUserDefaults] objectForKey:@"fb_accessToken"], nil];

[facebook requestWithGraphPath:@"PAGE_ID/likes" andParams:params andHttpMethod:@"POST" andDelegate:self];

I get the error message:

Error Domain=facebookErrDomain Code=10000 "The operation couldn’t be completed. (facebookErrDomain error 10000.)" UserInfo=0x624d560 {error=<CFBasicHash 0x6243fb0 [0x171e400]>{type = mutable dict, count = 2,
        entries =>
            2 : <CFString 0x624cec0 [0x171e400]>{contents = "type"} = <CFString 0x624bc40 [0x171e400]>{contents = "OAuthException"}
            3 : <CFString 0x624aaf0 [0x171e400]>{contents = "message"} = <CFString 0x6248b50 [0x171e400]>{contents = "(#3) Application does not have the capability to make this API call."}
        }
        }

This should be part of the Graph API because it says you can use that to "Like" any object with a /Likes connections. Any help?

Emissary answered 17/5, 2011 at 0:30 Comment(0)
T
5

Sorry to be the bearer of bad news, but apparently You can't like a Page on behalf of a user. You can, however, like posts, comments, and photos on behalf of a user.

Hope this makes sense, I've spent the last few hours trying to do simular.

Rich

Trellis answered 17/5, 2011 at 19:59 Comment(3)
The general consensus does seem to be that you can't like a page on behalf of the user, however I just had an ios game like a page on my behalf. Extreme Road Trip successfully manages to get you to like their own page. I wish I'd paid more attention when I did it now...Mathew
hi @Mathew ! i am looking for same case to like app's facebook page from ios app. did u find any way for liking app's own page from the app itself? built-in like action of facebook only allows to like objects ( comments, posts, photos) but not pages. any suggestion plz?Fondly
@wallacer! can you please answer on my question if u have came accross same issue. Thanks #14932001Fondly
T
0

https://developers.facebook.com/docs/reference/rest/stream.addLike/

and like a post

NSMutableDictionary* dict = [[[NSMutableDictionary alloc]initWithObjectsAndKeys:PostId,@"post_id",nil]autorelease];

[AppDelegate.facebook requestWithMethodName:@"stream.addLike" andParams:dict andHttpMethod:@"POST"  andDelegate:self];

and remove like

NSMutableDictionary* dict = [[[NSMutableDictionary alloc]initWithObjectsAndKeys:PostId,@"post_id",nil]autorelease];

[AppDelegate.facebook requestWithMethodName:@"stream.removeLike" andParams:dict andHttpMethod:@"POST"  andDelegate:self];`
Tenuous answered 24/2, 2012 at 8:49 Comment(0)
T
0

This appears to have recently changed, but now there is a new API - see https://developers.facebook.com/docs/opengraph/actions/builtin/likes/ for details.

Topo answered 17/10, 2012 at 19:50 Comment(0)
I
0

The second paragraph of the page linked by Eric Kassan states that: "The og.likes action can refer to any open graph object or URL, except for Facebook Pages or Photos."

Iberia answered 24/7, 2013 at 21:8 Comment(0)
C
-1

I have spent 10 hours for this solution.

But unfortunfortunitly there is not way.. even they have said "any object" in "likes" graph api but it's limited to only "users, it's posts, comments and photos".

Cantaloupe answered 7/5, 2012 at 19:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.