Google App Engine上的PHP SDK 4.0:cURL错误

时间:2015-05-15 22:16:33

标签: php facebook google-app-engine curl

我正在Google App Engine上运行PHP应用程序,并且我正在尝试实施Facebook登录。

访问登录网页后,我被重定向到Facebook,在我接受登录申请并获得重定向后,我收到错误"错误:此卷曲实施不支持选项10065 "

我启用了curl_lite,我暂时在localhost上运行它。这是我的代码:

<?php
session_start(); //Session should be active

#region Settings
$app_id             = 'xxxxxxx';  //Facebook App ID
$app_secret         = 'yyyyyyy'; //Facebook App Secret
$required_scope     = 'public_profile'; //Permissions required
$redirect_url       = 'http://localhost:8080/signup_fb.php'; //FB redirects to this page with a code
#endregion

#region Imports
//include autoload.php from SDK folder, just point to the file like this:
require_once "../libraries/facebook-php-sdk-v4-4.0-dev/autoload.php";

//import required class to the current scope
use Facebook\FacebookSession;
use Facebook\FacebookRequest;
use Facebook\FacebookRequestException;
use Facebook\GraphUser;
use Facebook\FacebookRedirectLoginHelper;
#endregion

FacebookSession::setDefaultApplication($app_id , $app_secret);
$helper = new FacebookRedirectLoginHelper($redirect_url);

//try to get current user session
try {
    $session = $helper->getSessionFromRedirect();
} catch(FacebookRequestException $ex) {
    die(" Error : " . $ex->getMessage());
} catch(\Exception $ex) {
    die(" Error : " . $ex->getMessage());
}

if ($session){ //if we have the FB session
    $user_profile = (new FacebookRequest($session, 'GET', '/me'))->execute()->getGraphObject(GraphUser::className());
    //do stuff below, save user info to database etc.

    echo $user_profile->getProperty('name');

}else{

    //display login url 
    $login_url = $helper->getLoginUrl( array( 'scope' => $required_scope ) );
    echo '<a href="'.$login_url.'">Login with Facebook</a>';
}

感谢您的回答:)

1 个答案:

答案 0 :(得分:0)

可以理解的是,启用curl_lite(由urlfetch支持的curl接口并且功能较少),您会看到这样的问题。 Check the docs正如另一位评论者提到的那样,如果您打算使用您的盒子的devserver作为Facebook登录流程的客户端运行这种特定的高级功能,那么您肯定应该使用真正的卷曲。