【问题标题】:PHP SDK 4.0 on Google App Engine: cURL errorGoogle App Engine 上的 PHP SDK 4.0:cURL 错误
【发布时间】:2015-05-15 22:16:33
【问题描述】:

我正在制作一个在 Google App Engine 上运行的 PHP 应用程序,并且我正在尝试实现 Facebook 登录。

访问登录网页后,我被重定向到 Facebook,在我接受登录应用程序并被重定向后,我收到错误“错误:此 curl 实现不支持选项 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>';
}

感谢您的回答:)

【问题讨论】:

标签: php facebook google-app-engine curl


【解决方案1】:

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

【讨论】:

  • 你能解决这个问题吗?我也无法让 facebook 登录与 appengine 一起工作,非常令人沮丧.....
  • 我的回答清楚地解释了这个问题 - 使用 UrlFetch 服务的“cURL lite”的功能不足以满足用户想要执行的操作。为此,他们应该遵循我提供的文档链接,该链接解释了如何启用 cURL 以使用套接字,这可能是必需的。
  • Managed VMs 使用 PHP 运行时运行 cURL 没有问题,就像在虚拟机上一样。我也建议阅读有关托管 VM 的信息。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-06-22
  • 1970-01-01
  • 2016-04-09
  • 2016-04-08
  • 1970-01-01
相关资源
最近更新 更多