在我说我想说的东西,我GOOGLEd了很多,有很多页面找到(包括许多这样的问题)与各种解决方案......但我已经尝试过他们每一个,但不幸的是他们都没有为我工作
与facebook-php-sdk我想登录一个用户。 最初几次它工作得很好(2到3天前)。。 今天,当我开始再次与我的项目工作,它不再工作。每当我尝试登录用户$facebook->getUser() is returning 0
。但3天后它工作。
我已经使用这里给出:: developers.facebook.com代码,是的,我已经做了一些修改那些在下面
我的代码:: 0auth_provided_by_facebook.php
include_once $_SERVER['DOCUMENT_ROOT'].'dist/facebook-php-sdk/src/facebook.php';
$config = array(
'appId' => '***********',
'secret' => '*********',
'allowSignedRequest' => false, // optional but should be set to false for non-canvas apps
'cookie' => true,
'oauth' => true
);
$facebook = new Facebook($config);
$user_id = $facebook->getUser();
if($user_id) {
try {
$user_profile = $facebook->api('/me','GET');
} catch(FacebookApiException $e) {
$login_url = $facebook->getLoginUrl(array(
scope'=>'email,user_location,user_photos,publish_actions,publish_stream,basic_info',
'redirect_uri' => 'http://localhost/dist/include/0auth_provided_by_facebook.php'
));
echo '<a href="' . $login_url .'"> PLEASE CLICK HERE </a>';
error_log($e->getType());
error_log($e->getMessage());
}
} else {
$login_url = $facebook->getLoginUrl(array(
'scope' => 'email,user_location,user_photos,publish_actions,publish_stream,basic_info',
'redirect_uri' => 'http://localhost/dist/include/0auth_provided_by_facebook.php'
));
echo '<a href="' . $login_url .'"> PLEASE CLICK HERE </a>';
}
OUTPUT给出完整的代码:getUser()总是返回0.
我的登录过程如下工作如何描述:点击<a href="login_fb">Login using fb </a>
控制后
去我localhost/dist/index.php
现在我的index.php include
上述wriiten代码是在不同的目录localhost/dist/include/0auth_provided_by_facebook.php
从这个文件我处理一切。在成功登录Facebook的回报价值的失败here.and然后在成功登录的用户再次重定向到家里
现在,这里是我的应用程序设置的,他完整列表,我启用或禁用或更改
1. App Domains : blank(according to the answer)
2. Site URL : `http://localhost/dist/include/0auth_provided_by_facebook.php?`
3. Native or desktop app? Disabled
4. Deauthorize Callback URL : `http://localhost/dist/include/0auth_provided_by_facebook.php?`
5. Social Discovery : enabled
6. Client OAuth Login : enabled
7. Embedded browser OAuth Login :enabled
8. App Secret Proof for Server API calls :enabled
9. Require 2-factor reauthorization : disabled
10. Valid OAuth redirect URIs :`http://localhost/dist/include/0auth_provided_by_facebook.php?` (according to the suggesion given in the answer)
11. Stream post URL security : enabled
这些是细节。在所有情况下,$user_id = $facebook-> getUser();
总是返回0
。我该如何解决它?
更多信息.. thhough我不知道它会帮你不要......我正在经历我base_facebook.php,我发现,这是因为
if(signed_request)
回到零点永远是假的。
替换现有
getCode()
功能为什么你有与该网站的DEAUTH回调相同的目标? –用户是否授权您的应用程序?流量是否发生,仍然得到用户ID 0?那是对的吗?这是你的问题吗? –
是用户授权应用......它在developers.facebook.com角色被提及....和 >还是你的用户ID为0?那是对的吗? 是这就是我的问题 –