Facebook访问令牌和应用程序设置配置问题

时间:2016-09-09 08:50:44

标签: php facebook facebook-graph-api facebook-access-token

首先让我澄清一下,我一直在那里抨击所有相关问题,但未能解决我的问题或理解我的问题。这就是为什么我在这里。

我有一个脚本要发布到我的Facebook页面和群组。显然它不起作用。为了整合我的其他代码,它过去常常被篡改代码。现在,我无法找到破坏性变化发生的地方。

问题描述:

在我试图获取页面/组列表的部分中,我无法这样做。因为我发现没有收到访问令牌。

代码的那部分(如果需要可以提供更多)

    $token_url = "https://graph.facebook.com/oauth/access_token?"
    . "client_id=".'xxxxxxxxxxxxxxxxxxxxxx'."&redirect_uri=" . urlencode($config['callback_url'])
    . "&client_secret=".'xxxxxxxxxxxxxxxxxxxxxxxxx'."&code=" .   $_GET['code'];

 echo $token_url;
 $response = file_get_contents($token_url);   // get access token from url

 echo $response;    

 $params = null;
 parse_str($response, $params);

 $_SESSION['token'] = $params['access_token'];

 echo "SESSION TOKEN : ".$_SESSION['token']."<br>"; 

$ _SESSION [&#39;令牌&#39;]什么都没有。也没有回应。

$ token_url输出以下内容;

https://graph.facebook.com/oauth/access_token?client_id=xxxxxxxxxxxxxxxxxxxxxxxxxxx&redirect_uri=http%3A%2F%2Fwww.landshoppe.com%2Ffb%2Findex.php%2F%3FfbTrue%3Dtrue&client_secret=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&code=AQC6FNR4fL0OdD8b6IuXut8Yv7d_-IE-uoGSsgzjCcnzXCI0DuAXJinU-4lonNZlcXeE50aztjYSVPAdJ4OAj91aLnzqrhkrfj69v7JkbOqCu0SqcIS2PvD2KrmefzRpr2K9ImCMxqtG82Hea6Bq6-FukHUCU9MiKJd_TLq5syhpEy5DPP-XGYnvI64l9rfenfDP4ODQ_tj3zm_duFVg9GoUwv_iayQ97UU5Wuq2skBbjCvfG_inzUOKx8RpE0SjNBZYIJ4aZeF0DC5TiFr1VQJxtp7zGBX_ANULWD4T4hbzpRUyWRJYpdIE1mav1vd2VoMpQFdGCf3cKUijJ6-I19Mi

回拨网址定义为

$config['callback_url']        =   'http://www.landshoppe.com/fb/index.php/?fbTrue=true'; //   /?fbTrue=true is required.

标题重定向到fb

header('location:https://www.facebook.com/dialog/oauth?client_id='.'xxxxxxxxxxxxxxxxxxxxxxx'.'&redirect_uri='.$config['callback_url'].'&scope=email,user_about_me,publish_actions,manage_pages');

我检查过的所有问题/讨论都主要针对像

这样的问题
  1. 重定向网址不匹配应有的差异,例如是否有&#39; www&#39;
  2. 重定向网址不匹配应有的差异,例如&#39; http&#39; /&#39; https&#39;
  3. 重定向网址没有尾随&#39; /&#39;
  4. 重定向Urls具有查询参数。
  5. 但是,我无法理解其中哪些适用于我。除了查询参数。这是必需的。

    我在我的Facebook登录产品中添加了许多URI到有效誓言URI

    http://www.landshoppe.com/fb/group.php/?fbTrue=true,http://landshoppe.com/fb/index.php/?fbTrue=true,http://landshoppe.com/fb/indextest.php/?fbTrue=truehttp://www.landshoppe.com/,http://www.landshoppe.com/fb/,http://landshoppe.com/,http://landshoppe.com/fb/,http://landshoppe.com/fb/index.php,http://www.landshoppe.com/fb/index.php/?fbTrue=true,http://www.landshoppe.com/fb/indextest.php/?fbTrue=true

    我哪里错了?它可能是应用程序设置之一吗?如果是这样,哪一个可能会干扰?由于Facebook应用程序设置对业余爱好者来说似乎很复杂,希望从Facebook应用专家那里找到解决方案。

1 个答案:

答案 0 :(得分:1)

我有访问令牌!问题是该应用程序被配置为桌面应用程序!

$ response错误输出未显示,因为设置了ob_start()输出缓冲。

在地址栏中执行$ token_url url,抛出错误。

相关问题