Reputation: 43
How to use this method with iOS sdk? How to send parameters?
For example http request will be something like this:
https://api.facebook.com/method/friends.areFriends?
uids1=10000179504****&
uids2=10000190198****&
access_token=...
Response:
[
{
"uid1": 10000179504****,
"uid2": 10000190198****,
"are_friends": true
}
]
How to remake it for obj c?
Upvotes: 0
Views: 496
Reputation:
Once you have a valid access token (as described in the sdk samples), you can do something like :
NSString *uids1 = @"10000179504****",*uids2 = @"10000190198****";
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
And then using the REST API :
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
uids1, @"uids1",
uids2, @"uids2",
nil];
[facebook requestWithMethodName:@"friends.areFriends"
andParams:params
andHttpMethod:@"GET"
andDelegate:self];
Or you can also use the Graph API, as the REST API will not be supported in the future
[facebook requestWithGraphPath:[NSString stringWithFormat:@"/%@/friends/%@",uids1,uids2] andDelegate:self];
Finally, you handle the response by implementing
- (void)request:(FBRequest *)request didLoad:(id)result;
Where result should be a dictionary (it won't be the same hierarchy inside the dictionary if you use the REST API or the Graph API). Don't forget to handle the errors too ;)
Upvotes: 2