Facebook Graph PHP FQL:好友照片权限(新 SDK)
无法弄清楚如何向我的访问令牌添加权限以访问朋友的照片。我有:
//auth user
if(empty($code)) {
$dialog_url = 'https://www.facebook.com/dialog/oauth?client_id='
. $app_id . '&redirect_uri=' . urlencode($my_url)
. '&scope=friends_photos';
echo("<script>top.location.href='" . $dialog_url . "'</script>");
}
//get user access_token
$token_url = 'https://graph.facebook.com/oauth/access_token?client_id='
. $app_id . '&redirect_uri=' . urlencode($my_url)
. '&client_secret=' . $app_secret
. '&code=' . $code
. '&scope=friends_photos';
$access_token = file_get_contents($token_url);
$fql_query_url = 'https://graph.facebook.com/'
. '/fql?q=SELECT+pid,object_id+FROM+photo_tag+WHERE+subject=301179'
. '&' . $access_token;
$graph_url = "https://graph.facebook.com/me?access_token="
. $access_token;
$user = json_decode(file_get_contents($graph_url));
$fql_query_result = file_get_contents($fql_query_url);
$fql_query_obj = json_decode($fql_query_result, true);
echo '<pre>';
print_r("query results:");
print_r($fql_query_obj);
查询返回空。
Can't figure out how to add permissions to my access token to access friends photos. I have:
//auth user
if(empty($code)) {
$dialog_url = 'https://www.facebook.com/dialog/oauth?client_id='
. $app_id . '&redirect_uri=' . urlencode($my_url)
. '&scope=friends_photos';
echo("<script>top.location.href='" . $dialog_url . "'</script>");
}
//get user access_token
$token_url = 'https://graph.facebook.com/oauth/access_token?client_id='
. $app_id . '&redirect_uri=' . urlencode($my_url)
. '&client_secret=' . $app_secret
. '&code=' . $code
. '&scope=friends_photos';
$access_token = file_get_contents($token_url);
$fql_query_url = 'https://graph.facebook.com/'
. '/fql?q=SELECT+pid,object_id+FROM+photo_tag+WHERE+subject=301179'
. '&' . $access_token;
$graph_url = "https://graph.facebook.com/me?access_token="
. $access_token;
$user = json_decode(file_get_contents($graph_url));
$fql_query_result = file_get_contents($fql_query_url);
$fql_query_obj = json_decode($fql_query_result, true);
echo '<pre>';
print_r("query results:");
print_r($fql_query_obj);
The query comes back empty.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该使用 OAuth 对话框 的
范围
(请参阅属性)向用户请求权限,稍后您只需使用他的access_token
。顺便说一句,
https://graph.facebook.com/oauth/access_token
没有参数perms
You should use
scope
of OAuth dialog (see properties) to request permissions from user, later you just use hisaccess_token
.BTW, there is no argument
perms
forhttps://graph.facebook.com/oauth/access_token