开发者

Facebook applicationAuthication Error

when i try to open my application http://apps.facebook.com/allmyfrnds/allmyfriends.php i get this error:

Fatal error: Call to undefined method Facebook::getSession() in E:\HostingSpaces\bombil\bombil.com\wwwroot\allmyfrnds\allmyfriends.php on line 14

MY CODE IS:

<?php  

   include_once ("src/facebook.php");  
   $app_id = '160888120643482';  
   $application_secret = 'bbae7def492082fa361da46185852e55';  

   $facebook = new Facebook(array(  
  'appId'  => $app_id,  
  'secret' => $application_secret,  
  'cookie' => true, // enable optional cookie support  
));  

    if ($facebook->getSession()) {  
    $user = $facebook->getUser();  
    $uid = $facebook->getUser();  
    $me = $facebook->api('/me/friends');  
    //echo "Total friends".sizeof($me['data'])."";  

    echo " <a href=\"http://www.bombil.com/\" target=\"_blank\" >Application Developed By Bombil Media</a> <br>";  
    foreach($me['data'] as $frns)  
    {  
    echo "<img src=\"https://graph.facebook.com/".$frns['id']."/picture\"" . "title=\"".$frns['name']."\"/".">";  

}  

    //echo " 

    //By <a href="\"http://facebook.com/nirbhay.singh\""><img src="\"https://graph.facebook.com/1147530774/picture\"" title="\"nirbhaysingh\"/"></a>";  

    }  
    else {  
    $loginUrl = "https://graph.facebook.com/oauth/authorize?type=user_agent&display=page&client_id=160888120643482
    &redirect_uri=http://apps.facebook.com/CANVAS URL/ 
    &scope=user_photos";  
    echo '<fb:redirect url="' . $loginUrl . '"></fb:redirect>';  
}  

?>  

But When i make upload this code

<?php  

   include_once ("src/facebook.php");  
   $app_id = '160888120643482';  
   $application_secret = 'bbae7def492082fa361da46185852e55';  

   $facebook = new Facebook(array(  
  'appId'  => $app_id,  
  'secret' => $application_secret,  
  'cookie' => true, // enable optional cookie support  
));  

    //if ($facebook->getSession()) {  
    $user = $facebook->getUser();  
    $uid = $facebook->getUser();  
    $me = $facebook->api('/me/friends');  
    //echo "Total friends".sizeof($me['data'])."";  

    echo " <a href=\"http://www.bombil.com/\" target=\"_blank\" >Application Developed By Bombil Media</a> <br>";  
    foreach(开发者_开发知识库$me['data'] as $frns)  
    {  
    echo "<img src=\"https://graph.facebook.com/".$frns['id']."/picture\"" . "title=\"".$frns['name']."\"/".">";  

}  

    //echo " 

    //By <a href="\"http://facebook.com/nirbhay.singh\""><img src="\"https://graph.facebook.com/1147530774/picture\"" title="\"nirbhaysingh\"/"></a>";  

    //}  
    //else {  
    //$loginUrl = "https://graph.facebook.com/oauth/authorize?type=user_agent&display=page&client_id=160888120643482
    //&redirect_uri=http://apps.facebook.com/CANVAS URL/ 
    //&scope=user_photos";  
    //echo '<fb:redirect url="' . $loginUrl . '"></fb:redirect>';  
//}  

?>  

I GET THIS ERROR:

Fatal error: Uncaught OAuthException: An active access token must be used to query information about the current user. thrown in E:\HostingSpaces\bombil\bombil.com\wwwroot\allmyfrnds\src\base_facebook.php on line 988

PLEASE HELP....I SHALL BE HIGHLY THANK FULL PLS


The code look Ok, the issue is you didnt login to retrieve the data. Before opening this page make sure you login with your code in same page or other pages. For quick verification, you just login with facebook.com first and try this page it should work.

The access token you need to get after successful login.


Fatal error: Uncaught OAuthException: An active access token must be used to query information about the current user. thrown in E:\HostingSpaces\bombil\bombil.com\wwwroot\allmyfrnds\src\base_facebook.php on line 988

for this problem surround your code with try { } catch statement.

Edit: Something like this

Probably the path in the include_once is incorrect.That is why you get the first error. Check the manual for more help.

<?php  
   include_once ("src/facebook.php");  
   $app_id = '160888120643482';  
   $application_secret = 'bbae7def492082fa361da46185852e55';  

  try {
   $facebook = new Facebook(array(  
     'appId'  => $app_id,  
     'secret' => $application_secret,  
     'cookie' => true, // enable optional cookie support  
    ));  

   if ($facebook->getSession()) {  
     $user = $facebook->getUser();  
     $uid = $facebook->getUser();  
     $me = $facebook->api('/me/friends');  
     //echo "Total friends".sizeof($me['data'])."";  

    echo " <a href=\"http://www.bombil.com/\" target=\"_blank\" >Application Developed By   Bombil Media</a> <br>";  
    foreach($me['data'] as $frns)  
    {  
      echo "<img src=\"https://graph.facebook.com/".$frns['id']."/picture\"" . "title=\"".$frns['name']."\"/".">"; 
    }
   }  
 } catch (FacebookApiException $e) {
      //echo "Error:" . print_r($e, true);
 }
?> 


If you are using linux server, then make sure the path is correct, also make sure file name is correct even for case sensitivity

include_once ("src/facebook.php");  
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜