Как получить идентификаторы пользователей после приглашения их в моем приложении Facebook? - PullRequest
0 голосов
/ 15 сентября 2011

Я использую этот код для получения приглашенных пользователей в мое приложение, но он не работает

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;
    }

}

Я могу получить идентификаторы запроса, но не могу получить идентификатор пользователя.

$from_id = $request_content['from']['id'];

и

$request_content['to']['id'];

ничего не возвращает ...

1 Ответ

1 голос
/ 16 сентября 2011

решение: -

первый:

$comma_separated = implode(",", $_REQUEST["request_ids"]);

, то:

$requests = explode(',',$comma_separated);

и, конечно:

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'];}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...