简体   繁体   English

抱歉,使用 PHP Facebook SDK 尝试登录以通过 facebook 工作时出现问题

[英]Sorry, something went wrong using PHP Facebook SDK trying login to get via facebook working

I get the error every time I try to I use the loginUrl.每次尝试使用 loginUrl 时都会收到错误消息。 I've done all the necessary things in facebook dev portal我已经在 facebook 开发门户中完成了所有必要的事情

<?php
session_start();
require( __DIR__.'/src/Facebook/autoload.php');

$fb = new Facebook\Facebook([
  'app_id' => '{}', // Replace {app-id} with your app id
  'app_secret' => '{}',
  'default_graph_version' => 'v2.5',
  ]);


$helper = $fb->getRedirectLoginHelper();
$permissions = ['email', 'user_posts']; // optional
$loginUrl    = $helper->getLoginUrl($callback, $permissions);
echo '<a href="' . $loginUrl . '">Log in with Facebook!</a>';
?>

Your app_id and app_secret shouldn't have {} around them.您的app_idapp_secret不应有{} And it might not be the best idea to post your app_secret here.在这里发布您的app_secret可能不是最好的主意。

So your code would be this:所以你的代码是这样的:

<?php
session_start();
require( __DIR__.'/src/Facebook/autoload.php');

$fb = new Facebook\Facebook([
  'app_id' => '119245818585909', // Replace {app-id} with your app id
  'app_secret' => '6a4bb23f0b6bc1c6b3f0cd6bf5e3239f',
  'default_graph_version' => 'v2.5',
  ]);


$helper = $fb->getRedirectLoginHelper();
$permissions = ['email', 'user_posts']; // optional
$loginUrl    = $helper->getLoginUrl($callback, $permissions);
echo '<a href="' . $loginUrl . '">Log in with Facebook!</a>';
?>
  1. please make sure that App Domains in settings is start with http or htttps.请确保设置中的 App Domains 以 http 或 htttps 开头。
  2. further make sure that Valid OAuth redirect URIs in "Facebook Login"进一步确保“Facebook 登录”中的有效 OAuth 重定向 URI

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

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