Lucy Weatherford
Lucy Weatherford

Reputation: 5544

Facebook Graph API GET http request, php

I'm trying to make a graph API GET request. It works in the Graph API explorer, but I can't seem to manage to have the application call it on its own.

I'm trying to retrieve the mutual friends in the user object. See documentation: https://developers.facebook.com/docs/reference/api/user/

    <?php

        $mutual = json_decode(file_get_contents("https://graph.facebook.com/".$fb_id."?".$access_token."/mutualfriends/".$other_fb_id));

    ?>

But this does not seem to be working.

Upvotes: 2

Views: 7635

Answers (1)

Juicy Scripter
Juicy Scripter

Reputation: 25938

You mixing URL arguments with path, it should be something like this (?access_token=... part should be placed at end):

$url = "https://graph.facebook.com/{$fb_id}/mutualfriends/{$other_fb_id}";
$url_with_token = $url . "?access_token={$access_token}";
$mutual = json_decode(file_get_contents($url_with_token));

Upvotes: 7

Related Questions