Facebook OAuth数据捕获 [英] Facebook OAuth Data Capturing

查看:147
本文介绍了Facebook OAuth数据捕获的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将来自Facebook的Oauth数据捕获到我的表格中,我已经写了这个代码

I need to capture Oauth data coming from facebook into my table , i have written this code

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

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

But it isn't displaying anything, How to capture Email ?

推荐答案

默认情况下,您不会从Graph API user 中获取 code>对象,需要通过传递字段明确地请求它。

You will not get email field by default from Graph API user object and need to explicitly request it by passing fields arguments.

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

这篇关于Facebook OAuth数据捕获的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆