douli6605 2014-05-22 15:48 采纳率: 100%
浏览 59

使用Facebook登录使用PHP sdk 4.0登录

I am trying to code Facebook log with php sdk 4.0 in to my website I have setup all the settings on my facebook app and im sure all the details are correct in my files. so my users can log in using they're Facebook account but I have run into a problem. I go to my website and click the log in link and it goes back to my website but this time it has a ?code= with lots of params and a error is displayed

And just to say the domain is a local domain I edited my hosts file and added

127.0.0.1 ashleyisawsome.com

And the error i have when i click login is

Fatal error: Class 'Facebook\FacebookCurlHttpClient' not found in C:\xampp\htdocs\fb\Facebook\FacebookRequest.php on line 154

I looked in FacebookRequest.php and all i found was the line below

return static::$httpClientHandler ?: static::$httpClientHandler = new FacebookCurlHttpClient();

So i am guessing the error is with the

new FacebookCurlHttpClient();

Can anyone help me out with this please? Here is my main index.php file

<?php

 session_start();
 include 'Facebook/FacebookSession.php';
 include 'Facebook/FacebookRedirectLoginHelper.php';
 require_once( 'Facebook/FacebookRequest.php' );
 require_once( 'Facebook/FacebookResponse.php' );
 require_once( 'Facebook/FacebookSDKException.php' );
 require_once( 'Facebook/FacebookRequestException.php' );
 require_once( 'Facebook/FacebookAuthorizationException.php' );
 require_once( 'Facebook/GraphObject.php' );
 require_once( 'Facebook/GraphUser.php' );
 Use Facebook\FacebookSession;
 Use Facebook\FacebookRedirectLoginHelper;
 use Facebook\FacebookRequest;
 use Facebook\FacebookResponse;
 use Facebook\FacebookSDKException;
 use Facebook\FacebookRequestException;
 use Facebook\FacebookAuthorizationException;
 use Facebook\GraphObject;
 use Facebook\GraphUser;
 FacebookSession::setDefaultApplication('',     '');
 $helper = new FacebookRedirectLoginHelper('http://ashleyisawsome.com/fb/index.php');
 $session = $helper->getSessionFromRedirect();
 if($session != NULL){
 echo "Logged In !<br>"; 
 $request = new FacebookRequest($session, 'GET', '/me');
 $response = $request->execute();
 $graph = $response->getGraphObject(GraphUser::className());
 echo $graph->getName();
 }
 else{
 echo '<a href="' . $helper->getLoginUrl() . '">Login</a>';
 }
 ?>

EDIT : I have fixed this but it know says this?

Fatal error: Interface 'Facebook\FacebookHttpable' not found in C:\xampp\htdocs\fb\Facebook\FacebookCurlHttpClient.php on line 31
  • 写回答

1条回答 默认 最新

  • dongrongdao8902 2014-05-28 21:29
    关注

    You must include / call the FacebookHttpable class / namespace -BEFORE- the FacebookCurlHttpClient class / namespace

    //all other requires here
    require_once( 'FacebookHttpable.php' );
    require_once( 'FacebookCurlHttpClient.php' );
    
    //all other namespaces here
    use Facebook\FacebookHttpable;
    use Facebook\FacebookCurlHttpClient;
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?