我尝试为我的网站使用facebook API。但是我得到这样的错误
致命错误:未捕获的卷曲异常:1:不支持协议 https 或在 libcurl 中禁用 /home/batav1/public_html/permaisuri/include/fbsdk/src/base_facebook.php 在 887 行
我检查了 curl 配置 bu 键入 phpinfo(),这是结果
cURL support enabled
cURL Information libcurl/7.21.0 zlib/1.2.3 libidn/0.6.5
我该怎么办?这是我的代码:
<?php
require 'include/fbsdk/src/facebook.php';
$facebook = new Facebook(array(
'appId' => '33025497038xxxx',
'secret' => '87be6ab5175a9be7c7d48be74dd5xxxx',
));
$user = $facebook->getUser();
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
if ($user) {
$logoutUrl = $facebook->getLogoutUrl();
} else {
$loginUrl = $facebook->getLoginUrl();
}
$naitik = $facebook->api('/naitik');
?>
<!doctype html>
<html xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<title>php-sdk</title>
<style>
body {
font-family: 'Lucida Grande', Verdana, Arial, sans-serif;
}
h1 a {
text-decoration: none;
color: #3b5998;
}
h1 a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<h1>php-sdk</h1>
<?php if ($user): ?>
<a href="<?php echo $logoutUrl; ?>">Logout</a>
<?php else: ?>
<div>
Login using OAuth 2.0 handled by the PHP SDK:
<a href="<?php echo $loginUrl; ?>">Login with Facebook</a>
</div>
<?php endif ?>
<h3>PHP Session</h3>
<pre><?php print_r($_SESSION); ?></pre>
<?php if ($user): ?>
<h3>You</h3>
<img src="https://graph.facebook.com/<?php echo $user; ?>/picture">
<h3>Your User Object (/me)</h3>
<pre><?php print_r($user_profile); ?></pre>
<?php else: ?>
<strong><em>You are not Connected.</em></strong>
<?php endif ?>
<h3>Public profile of Naitik</h3>
<img src="https://graph.facebook.com/naitik/picture">
<?php echo $naitik['name']; ?>
</body>
</html>
似乎您的 php 设置似乎不支持 https
包装器
要降低https包装器:- php_openssl
扩展必须存在并启用 - allow_url_include
必须设置为开
在 php.ini 文件中,如果不存在,请添加以下行:
extension=php_openssl.dll
allow_url_include = On
问题是 curl 扩展没有编译 ssl 支持。你应该使用 --with-curl 和 --with-openssl 选项重新编译 PHP。
希望有帮助。