2012-06-20 98 views
0

我嘗試爲我的網站使用Facebook API。 但我得到這樣Facebook SDK cURL和SSL錯誤

Fatal error: Uncaught CurlException: 1: Protocol https not supported or disabled in libcurl thrown in /home/batav1/public_html/permaisuri/include/fbsdk/src/base_facebook.php on line 887

一些錯誤我檢查捲曲的配置卜打字的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> 

回答

-1

看來,你的PHP安裝似乎並不支持https包裝

要alow HTTPS wraper: - 在php_openssl擴展必須存在並啓用 - allow_url_include必須設置爲上

在php.ini

文件添加此行如果不存在:

extension=php_openssl.dll 

allow_url_include = On 
+0

他使用curl,所以allow_url_include不是必需的。 – Maerlyn

+0

oke,謝謝,我會先試試吧 – nvl

+1

而你使用的是windows dll,而根據錯誤及其/ home/..路徑我猜他是在linux/unix變種... – stUrb

-1

問題是curl擴展沒有編譯的ssl支持。您應該使用--with-curl和--with-openssl選項重新編譯PHP。

希望有所幫助。

+0

oke謝謝,我會試試 – nvl

+0

我檢查了我的命令,好像已經執行了--with-curl。 --with-openssl應該執行嗎? – nvl