Facebook 应用程序身份验证错误

发布于 2024-11-16 22:36:43 字数 3435 浏览 0 评论 0原文

当我尝试打开我的应用程序时 http://apps.facebook.com/allmyfrnds/allmyfriends.php 我收到此错误:

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

我的代码是:

<?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>';  
}  

?>  

但是当我上传此代码时

<?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>';  
//}  

?>  

,我收到此错误:

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

请帮助....我将非常感谢您的帮助

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

少女的英雄梦 2024-11-23 22:36:43

代码看起来不错,问题是您没有登录来检索数据。
在打开此页面之前,请确保您在同一页面或其他页面中使用代码登录。
为了快速验证,您只需先登录 facebook.com 并尝试此页面,它应该可以工作。

登录成功后需要获取的访问令牌。

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.

贩梦商人 2024-11-23 22:36:43
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

对于这个问题,请使用 try { } catch 语句包围您的代码。

编辑:类似这样的东西

可能 include_once 中的路径不正确。这就是您收到第一个错误的原因。查看手册以获取更多帮助。

<?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);
 }
?> 
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);
 }
?> 
深居我梦 2024-11-23 22:36:43

如果您使用的是 Linux 服务器,请确保路径正确,并确保文件名正确(即使区分大小写)

include_once ("src/facebook.php");  

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");  
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文