我在发布Facebook开放图的操作时遇到问题。
一旦我从我的用户帐户中删除该应用程序,然后重新允许它,我就会收到以下错误:
Error occured
Type: OAuthException
Message: Error validating access token: Session has expired at unix time 1328533200. The current unix time is 1238541149.
有趣的是,每次我尝试发布操作时,会话过期时间代码都是相同的。我假设这是我取消应用程序授权的时间代码。
我使用的代码是这样的:〔删除私人详细信息〕
<script type="text/javascript">
function read() {
FB.api('/me/nmaespace:read' +
'?article=http://domain.com/post.php?id=<?php echo $linkid; ?>&access_token=accesssdfsdfssd',
'post',
function(response) {
var msg = 'Error occured';
if (!response || response.error) {
if (response.error) {
msg += "'n'nType: "+response.error.type+"'n'nMessage: "+response.error.message;
} alert(msg);
} else { alert('Post was successful! Action ID: ' + response.id);}
});
}
</script>
我能做些什么来阻止这种情况的发生并使我的代码正常工作?
提前感谢
删除应用程序时,其身份验证令牌将被永久吊销。
您需要请求用户重新授权并收集新授权令牌。
一个简单的解决方案是请求离线权限,这将为您提供一个不会过期的长寿命令牌。只需将其添加到您的请求范围中即可。