Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Facebook OAuth数据捕获_Php_Facebook_Json_Facebook Graph Api_Oauth - Fatal编程技术网

Php Facebook OAuth数据捕获

Php Facebook OAuth数据捕获,php,facebook,json,facebook-graph-api,oauth,Php,Facebook,Json,Facebook Graph Api,Oauth,我需要将来自facebook的Oauth数据捕获到我的表中,我已经编写了以下代码 $app_id = "340088232675552"; $canvas_page = "https://apps.facebook.com/appluckyprice/index.php"; $auth_url = "https://www.facebook.com/dialog/oauth?client_id=" . $app_id . "&redirect_uri=" . urlencode

我需要将来自facebook的Oauth数据捕获到我的表中,我已经编写了以下代码

$app_id = "340088232675552";
$canvas_page = "https://apps.facebook.com/appluckyprice/index.php";
$auth_url = "https://www.facebook.com/dialog/oauth?client_id=" 
    . $app_id . "&redirect_uri=" . urlencode($canvas_page) . "&scope=email,user_birthday,user_hometown";
我正在使用

$data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);
$graph_url = 'https://graph.facebook.com/'.$data["user_id"].'';
$user = json_decode(file_get_contents($graph_url));

$user_email = $data['user']->email;
echo $user_email;

但它没有显示任何内容,如何捕获电子邮件?

默认情况下,您不会从Graph API
user
对象中获得
电子邮件
字段,需要通过传递
字段
参数来显式请求它

$graph_url = 'https://graph.facebook.com/me?fields=email&access_token='.$data["oauth_token"];