簡體   English   中英

邀請他們加入我的Facebook應用程序后如何檢索用戶ID?

[英]how to retrive the users ids after inviting them to my facebook application?

我正在使用此代碼將邀請的用戶吸引到我的應用程序中,但是它不起作用

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

}

我可以獲取請求ID,但無法檢索用戶ID。

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

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

什么都不返回...

解:-

第一:

$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'];}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM