Facebook 应用程序身份验证错误
当我尝试打开我的应用程序时 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
代码看起来不错,问题是您没有登录来检索数据。
在打开此页面之前,请确保您在同一页面或其他页面中使用代码登录。
为了快速验证,您只需先登录 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.
对于这个问题,请使用 try { } catch 语句包围您的代码。
编辑:类似这样的东西
可能 include_once 中的路径不正确。这就是您收到第一个错误的原因。查看手册以获取更多帮助。
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.
如果您使用的是 Linux 服务器,请确保路径正确,并确保文件名正确(即使区分大小写)
If you are using linux server, then make sure the path is correct, also make sure file name is correct even for case sensitivity