授予权限和范围的万岁访问令牌

时间:2014-12-02 07:59:01

标签: php facebook-graph-api

我使用图形api资源管理器获取了我的脸书应用程序的访问令牌,还从服务器端获取了长期访问令牌。但我无法编辑我为长期访问令牌获得的权限和范围。 我已经上传了访问令牌调试器的屏幕截图,用于从图api资源管理器获取的访问令牌以及从服务器端获得的长期访问令牌。请帮助如何编辑服务器端长期访问令牌的范围。

enter image description here

如在范围内的屏幕截图中所示,它具有如此多的权限。但是我从服务器端获得的访问令牌只有一个范围“public_profile”。我应该如何授予从服务器端获得的长期访问令牌的权限?请帮忙

我的登录代码

<?php



$a=$_GET["query"];




  $app_id = "xxxxxx";
  $app_secret = "xxxxxxxxxx"; 
  $redirect_uri = "http://localhost/url_encode.php/"."?"."f=".$a;
 // echo $my_url;


$dialog_url = "http://www.facebook.com/dialog/oauth?client_id=" 
      . $app_id . "&redirect_uri=" .$redirect_uri;

    echo("<script> top.location.href='" . $dialog_url 
      . "'</script>");


My code for generating the long lived access token.

      <?php
//include ('search_query.php');

$b=$_GET['code'];
$c=$_GET['f'];
//echo $b;
//echo "<br>";
//echo "<br>";
//echo $c;
//$a=$_GET['f'];


$redirect_uri="http://localhost/url_encode.php/"."?"."f=".$c;


if(empty($b)){

  $dialog_url = "http://www.facebook.com/dialog/oauth?client_id=" 
      . $app_id . "&redirect_uri=" .$redirect_uri;

    echo("<script> top.location.href='" . $dialog_url 
      . "'</script>");





}


$token_url="https://graph.facebook.com/oauth/access_token?client_id=xxxxxx&redirect_uri=".$redirect_uri."&client_secret=xxxxxxxxx&code=".$b;
$access_token=file_get_contents($token_url);

//echo $access_token;
$position_of_string=strpos($access_token ,"&");
$actual_access_token=substr($access_token,0,$position_of_string);
echo $actual_access_token;

$url="https://graph.facebook.com/".urlencode($c);
$json_object=file_get_contents($url);

&GT;

1 个答案:

答案 0 :(得分:1)

您在登录流程中缺少范围参数:https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow/v2.2

  

范围:以逗号分隔的请求权限列表   使用你的应用程序的人。

相关问题