简体   繁体   English

使用PHP SDK在Facebook上进行APP身份验证

[英]APP authentication on facebook with PHP SDK

I have a problem with authenticating my Facebook APP with a Link generated through the Facebook PHP SKD: 使用通过Facebook PHP SKD生成的链接对我的Facebook APP进行身份验证时遇到问题:

when I click the link, an error appears on facebook (An error occurred. Please try again later.) and I won't get redirected to the "app login page". 当我单击链接时,facebook上出现错误(发生错误。请稍后重试。),并且我不会重定向到“应用程序登录页面”。

https://www.facebook.com/dialog/oauth?redirect_uri=http%3A%2F%2Fxxx.test.net%2Fstart.php&state=8d0ea10xxxxxxx290be6c654f02xxxa&scope=user_likes https://www.facebook.com/dialog/oauth?redirect_uri=http%3A%2F%2Fxxx.test.net%2Fstart.php&state=8d0ea10xxxxxxx290be6c654f02xxxa&scope=user_likes

This is the code of the index.php: 这是index.php的代码:

<?php
  require_once("./fbsdk/facebook.php");
//test.net
  $config = array();
  $config[‘appId’] = '37353621936xxxx'; 
  $config[‘secret’] = 'fd39e0f0861f2bdae4fc79274749xxxx';
  $config[‘fileUpload’] = false; // optional

  $facebook = new Facebook($config);

?>
<!DOCTYPE html>
<html>
<head>
<title>
FB-DEV-TEST
</title>

</head>
<body>


<?php

$params = array(
  'scope' => 'user_likes',
  'redirect_uri' => 'http://xxx.test.net/start.php'
);

$loginUrl = $facebook->getLoginUrl($params);

echo "<a href=\"$loginUrl\">Login</a>";

?>


</body>
</html>

I've already read this post, but I still can't figure out the problem... are there any changes I have to do at the Facebook APP center, before I can login? 我已经阅读了这篇文章,但是我仍然无法解决问题...在登录之前,我必须在Facebook APP中心进行任何更改吗? Thanx for your help & sry, for my bad english! 感谢您的帮助和对不起,我的英语不好! :) :)

检查您的redirect_url域是否与developers.facebook.com上的“应用程序设置”中的“站点URL:”匹配。

A few checklists that I can think of: 我能想到的一些清单:

  • Make sure your Facebook app is not in sandbox mode (unless you are already signed in to your Facebook account before clicking on the login link) 确保您的Facebook应用程序不在沙盒模式下(除非您已经在单击登录链接之前登录到Facebook帐户)

  • At https://developers.facebook.com/apps/ : https://developers.facebook.com/apps/上
    "Website with Facebook Login" must be checked, but for "Site URL", you can enter any landing URL. 必须选中“具有Facebook登录名的网站”,但是对于“站点URL”,您可以输入任何登录URL。

  • Also at https://developers.facebook.com/apps/ : 同样在https://developers.facebook.com/apps/上
    Make sure that your site domain is entered under App Domains. 确保在“应用程序域”下输入您的站点域。

Alternatively, you may want to check out Opauth , an authentication framework for PHP that handles these for you. 另外,您可能想查看Opauth ,这是一个PHP身份验证框架,可以为您处理这些问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM