无法连接到graph.facebook.com端口443:连接被拒绝

时间:2016-04-28 08:29:34

标签: php facebook facebook-graph-api

我是FB图形API的新手,我尝试在我的网站中包含FB登录,我从他们的网站上关注官方FB登录教程,但登录后我收到以下错误:

declare @i nvarchar(max)='"Information": {
        "Name": [],
        "Class": [],
        "Degree": ["Graduate or professional degree"],
        "major": [],
        "skill": [],
        "expLevel": ["0 to 2 years",
                     "Not available",
                     "3 to 5 years"],
        "certificationtype": ""
    }'

-- 1st method
select replace(@i, 'Not available', 'Not listed')

-- 2nd method which is more accurate
select replace(substring(col1,0,charindex(']',col1)),'Not available', 'Not listed') from
(select substring (@i,charindex('expLevel"',@i)+len('expLevel"')+1,len(@i)) Col1)t4

的login.php

Failed to connect to graph.facebook.com port 443: Connection refused

登录-callback.php

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

$fb = new Facebook\Facebook([
'app_id' => 'xxx',
'app_secret' => 'xxx',
'default_graph_version' => 'v2.3',
// . . .
]);

$helper = $fb->getRedirectLoginHelper();
$permissions = ['public_profile', 'email']; // optional
$loginUrl = $helper->getLoginUrl('http://-myserver-/login-callback.php',    $permissions);

echo '<a href="' . $loginUrl . '">Log in with Facebook!</a>';
?>

例如帆布-app.php

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

$fb = new Facebook\Facebook([
'app_id' => 'xxx',
'app_secret' => 'xxx',
'default_graph_version' => 'v2.3',
// . . .
]);



$helper = $fb->getRedirectLoginHelper();
try {
$accessToken = $helper->getAccessToken();
} catch(Facebook\Exceptions\FacebookResponseException $e) {
// When Graph returns an error
echo 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
// When validation fails or other local issues
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}

if (isset($accessToken)) {
// Logged in!
$_SESSION['facebook_access_token'] = (string) $accessToken;

// Now you can redirect to another page and use the
 // access token from $_SESSION['facebook_access_token']
}
?>

我已经在堆栈和谷歌搜索但我无法找到任何解决方案

1 个答案:

答案 0 :(得分:5)

Hostinger的免费服务器不允许连接到客户服务部门提到的Fb SDK。