i want to fetch Facebook Mutual friends in my ios App
this is my try to get mutual friends i call with this Link
[NSString stringWithFormat:@\"me/mutua
Yes, quite easy solution i have for you.
NSString *myFriendId = [NSString stringWithFormat:@"/%@",#YourFriendId#];
NSString *hashedAccessToken = [self hmac:accessToken withKey:kAPP_SECRETE];
NSDictionary *params = @{
@"fields" : @"context.fields(mutual_friends)",
@"appsecret_proof" : hashedAccessToken,
@"access_token" : accessToken
};
/* make the API call */
[FBRequestConnection startWithGraphPath:myFriendId parameters:params HTTPMethod:@"GET" completionHandler:^
(
FBRequestConnection *connection, id result, NSError *error
){//Handle Respons;}];
And here is the hmac function (Add #import )
//SHA256 HASHMAC
- (NSString *)hmac:(NSString *)access_token withKey:(NSString *)app_secret
{
const char *cKey = [app_secret cStringUsingEncoding:NSASCIIStringEncoding];
const char *cData = [access_token cStringUsingEncoding:NSASCIIStringEncoding];
unsigned char cHMAC[CC_SHA256_DIGEST_LENGTH];
CCHmac(kCCHmacAlgSHA256, cKey, strlen(cKey), cData, strlen(cData), cHMAC);
NSData *HMACData = [NSData dataWithBytes:cHMAC length:sizeof(cHMAC)];
const unsigned char *buffer = (const unsigned char *)[HMACData bytes];
NSMutableString *HMAC = [NSMutableString stringWithCapacity:HMACData.length * 2];
for (int i = 0; i < HMACData.length; ++i){
[HMAC appendFormat:@"%02x", buffer[i]];
}
return HMAC;
}
You're using the wrong endpoint syntax, as @CBroe already pointed out, and which is also clear from the docs.
You need to use
/{user-id}.context/mutual_friends
The {user-id}
is the user you're interested in, and the "other" user is the one which Access Token was used for the request. This ONLY works for users which are both already users of your app.