gpt4 book ai didi

php - 无法连接到 graph.facebook.com 端口 443 : Connection refused

转载 作者:行者123 更新时间:2023-12-02 19:43:24 24 4
gpt4 key购买 nike

我是 FB 图形 API 的新手,我尝试在我的网站中包含 FB 登录,我按照他们网站上的官方 FB 登录教程进行操作,但登录后出现以下错误:

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

登录.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>';
?>

登录回调.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']
}
?>

示例-canvas-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->getCanvasHelper();
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.
}
?>

我已经在 stack 和 google 中搜索过,但找不到任何解决方案

最佳答案

正如其客户服务所提到的,Hostinger 的免费服务器不允许连接到 Facebook 的 SDK。

关于php - 无法连接到 graph.facebook.com 端口 443 : Connection refused,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36909261/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com