无法弄清楚如何为我的访问令牌添加权限以访问朋友的照片。我有:
//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);
查询返回空白。
答案 0 :(得分:1)
您应该使用OAuth dialog的scope
(请参阅属性)向用户请求权限,稍后您只需使用他的access_token
。
$dialog_url = 'https://www.facebook.com/dialog/oauth?client_id='
. $app_id . '&redirect_uri=' . urlencode($my_url)
. '&scope=friends_photos';
顺便说一句,perms
https://graph.facebook.com/oauth/access_token