我有Facebook的Flash游戏。昨天它工作正确,成功地将数据插入数据库,但现在当我尝试启动我的应用程序/游戏时出现错误:Fatal error: Uncaught OAuthException: An active access token must be used to query information about the current user. thrown in /home/padekime/domains/padekime.eu/public_html/images/base_facebook.php on line 1254
这是我的代码:
<?php
$request = $_REQUEST["signed_request"];
list($encoded_sig, $load) = explode('.', $request, 2);
$fbData = json_decode(base64_decode(strtr($load, '-_', '+/')), true);
if (!empty($fbData["page"]["liked"]))
{ ?>
<?php
require_once('images/Facebook.php');
$facebook = new Facebook(array(
'appId' => 'yyyyyyyyyyyyyyyyyyyyyyy',
'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx',
));
# Get User ID
$user = $facebook->getUser();
$user_profile = $facebook->api('/me');
$coded = $_REQUEST['code'];
$name = "".$user_profile['name']."";
if ($user) {
try {
?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-8" />
<title>Eurokos</title>
</head>
<body bgcolor="#ffffff">
<!--url's used in the movie-->
<!--text used in the movie-->
<!-- saved from url=(0013)about:internet -->
<center>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="550" height="643" id="Eurokos" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="Memory22.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="Memory22.swf" quality="high" bgcolor="#ffffff" width="550" height="643" name="Eurokos" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</center>
</body>
</html>
<?php
echo "Name: " . $user_profile['name'];
$name = $user_profile['name'];
session_start();
$_SESSION['vardas'] = $name;
echo $facebook->getAccessToken();
$apiResponse = $facebook->api('/me/photos', 'POST', $post_data);
} catch (FacebookApiException $e) {
$user = null;
error_log($e);
}
} else {
$redirectUri = 'http://www.facebook.com/JuokoEra/app_156187751211405?ref=ts';
$loginUrl = $facebook->getLoginUrl( array(
'scope' => 'publish_stream,photo_upload',
'redirect_uri' => $redirectUri
));
echo("<script>top.location.href = '" . $loginUrl . "';</script>");
}
?>
<html>
<?php
?>
<a href="band.php?varname=<?php echo $name ?>">Page2</a>;
<form method="post" action="band.php">
<input type="hidden" name="vardas" value="$name">
<input type="submit">
</form>
</body>
</html>
<?php }else {?>
<?php
//$link = 'http://www.google.lt'; // url link
//$src = 'http://www.juokoera.lt/plaukai/images/PlaukaiNeuzvedus.jpg'; // image url
//echo '<a href="'. $link .'"><img style="border:none;" src="'. $src .'" /></a>';
?> <div align="center"><?php
$image_off = 'http://www.juokoera.lt/atostogos/images/atostogosU.jpg';
$image_on = 'http://www.juokoera.lt/atostogos/images/atostogosN.jpg';
echo '<img src="http://www.juokoera.lt/atostogos/images/atostogosN.jpg" onmouseover="this.src=\''.$image_off.'\';" onmouseout="this.src=\''.$image_on.'\';"/>';
?></div>
<?php } ?>
我不知道什么是错的,昨天它工作了,这个echo $facebook->getAccessToken();
返回了访问令牌,但今天的应用程序不起作用。你可以帮帮我吗?谢谢。
答案 0 :(得分:0)
access_token仅在一小时内有效,除非您已将其转换为长期访问令牌。如果access_token返回错误,建议您让用户再次登录或使用JavaScript SDK为用户获取新令牌(您可以使用函数FB.getLoginStatus()
函数)
如果用户更改了密码,access_token也会过期。