我已经在facebook连接几天了,我只使用从facebook下载的PHP SDK。
我首先使用了一些自定义代码,但在失败后我只是在facebook上复制了代码,但这仍然失败。
我有什么问题吗?我在facebook上创建了一个应用程序,添加了正确的域名(我得到了正确的重定向)。 一旦人们登录,这是他们被重定向到的URL:
http://www.mysite.com/index.php?state=33e35654a84559d246c152ed10e8150b&code=AQBGxCMu4vgbw5HgU8EIoyq8rhuHaKvtJQR-VbPMVH8bd2JMIRcxojqJ-l7XrjIdG9TNN05el14Jv8isbHbUWj9so-CdhaEqj7tLR-Rj6-JaOTA7QErrpfN_0XQN1CGCmvmTL6ZtoUupgkVwkzq_CWDT9lSoDPvNHu2F67Jqlsi2DfQZGE1J7pDzujBoSoJhDhs#_=_
我从facebook复制的代码:
<?
// Remember to copy files from the SDK's src/ directory to a
// directory in your application on the server, such as php-sdk/
require_once('classes/facebook/facebook.php');
$config = array(
'appId' => 'appID here',
'secret' => 'secret here',
);
$facebook = new Facebook($config);
$user_id = $facebook->getUser();
?>
<html>
<head></head>
<body>
<?
if($user_id) {
// We have a user ID, so probably a logged in user.
// If not, we'll get an exception, which we handle below.
try {
$user_profile = $facebook->api('/me','GET');
echo "Name: " . $user_profile['name'];
} catch(FacebookApiException $e) {
// If the user is logged out, you can have a
// user ID even though the access token is invalid.
// In this case, we'll get an exception, so we'll
// just ask the user to login again here.
$login_url = $facebook->getLoginUrl();
echo 'Please <a href="' . $login_url . '">login.</a>';
error_log($e->getType());
error_log($e->getMessage());
}
} else {
// No user, print a link for the user to login
$login_url = $facebook->getLoginUrl();
echo 'Please <a href="' . $login_url . '">login.</a>';
}
?>
</body>
</html>
答案 0 :(得分:0)
事实证明它与证书有关,经过一些环顾四周我发现了改变
if (curl_errno($ch) == 60) {
// CURLE_SSL_CACERT
到
if (curl_errno($ch) == 60 || curl_errno($ch) == 77) {
// CURLE_SSL_CACERT
解决问题