我正在使用此代码将受邀用户提交给我的应用程序,但它无效
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'];
什么都不返回......
答案 0 :(得分:1)
的解决方案: -
第一
$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'];}