Reputation: 1910
i'm using this code to get the invited users to my application but it is not working
if (isset($_REQUEST['request_ids']))
{
$APPLICATION_ID = "2222222222222222";
$APPLICATION_SECRET = "sfgjjksjlfansnmeasdedxcxcvxdfsda";
$token_url = "https://graph.facebook.com/oauth/access_token?" . "client_id=" . $APPLICATION_ID . "&client_secret=" . $APPLICATION_SECRET . "&grant_type=client_credentials";
$app_token = file_get_contents($token_url);
$requests = explode(',',$_REQUEST['request_ids']);
foreach($requests as $request_id) {
$request_content = json_decode(file_get_contents("https://graph.facebook.com/" . $request_id . "?" . $app_token), TRUE);
$from_id = $request_content['from']['id'];
$to_id = $request_content['to']['id'];
echo $from_id . " - " . $to_id;
}
}
i can get the request ids but i can't retrieve the users id.
$from_id = $request_content['from']['id'];
and
$request_content['to']['id'];
returns nothing...
Upvotes: 0
Views: 297
Reputation: 1910
solution:-
first:
$comma_separated = implode(",", $_REQUEST["request_ids"]);
then:
$requests = explode(',',$comma_separated);
and of course:
foreach($requests as $request_id)
{
$request_content = json_decode(file_get_contents("https://graph.facebook.com/" . $request_id . "?" . $app_token), TRUE);
$from_id = $request_content['from']['id'];
$to_id = $request_content['to']['id'];}
Upvotes: 1