Javascript 必须使用活动访问令牌来查询具有open graph的当前用户的信息
大家好,我正在尝试发布我的facebook应用程序用户的活动,我一步一步地遵循教程,但它不能正常工作 警报消息向我显示错误“发生错误必须使用活动访问令牌查询有关当前用户的信息”为什么??我记对了 代码如下:Javascript 必须使用活动访问令牌来查询具有open graph的当前用户的信息,javascript,facebook,facebook-graph-api,Javascript,Facebook,Facebook Graph Api,大家好,我正在尝试发布我的facebook应用程序用户的活动,我一步一步地遵循教程,但它不能正常工作 警报消息向我显示错误“发生错误必须使用活动访问令牌查询有关当前用户的信息”为什么??我记对了 代码如下: <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US" xmlns:fb="https://www.facebook.com/2008/fbml"> <head prefix="og: htt
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"
xmlns:fb="https://www.facebook.com/2008/fbml">
<head prefix="og: http://ogp.me/ns# appnamespace:
http://ogp.me/ns/apps/appnamespace#">
<title>OG Tutorial App</title>
<meta property="fb:app_id" content="appID" />
<meta property="og:type" content="appnamespace:recipe" />
<meta property="og:title" content="Stuffed Cookies" />
<meta property="og:image" content="http://www.domain.com/logo.gif" />
<meta property="og:description" content="The Turducken of Cookies" />
<meta property="og:url" content="http://www.domain.com/activity.php">
<script type="text/javascript">
function postCook()
{
FB.api(
'/me/namespace:cook',
'post',
{ recipe: 'http://www.domain.com/activity.php' },
function(response) {
if (!response || response.error) {
alert('Error occured '+ response.error.message); // it shows "Error occured An active access token must be used to query information about the current user." message
} else {
alert('Cook was successful! Action ID: ' + response.id);
}
});
}
</script>
</head>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'appID', // App ID
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
<h3>Stuffed Cookies</h3>
<p>
<img title="Stuffed Cookies"
src="http://www.domain.com/logo.gif"
/>
</p>
<br>
<form>
<input type="button" value="Cook" onclick="postCook()" />
</form>
</body>
</html>
OG教程应用程序
函数postCook()
{
FB.api(
“/me/namespace:cook”,
"岗位",,
{配方:'http://www.domain.com/activity.php' },
功能(响应){
如果(!response | | response.error){
警报('Error occurrend'+response.Error.message);//它显示“Error occurrent必须使用活动访问令牌查询有关当前用户的信息。”消息
}否则{
警报('Cook成功!操作ID:'+响应.ID);
}
});
}
window.fbAsyninit=函数(){
FB.init({
appId:'appId',//应用程序ID
状态:true,//检查登录状态
cookie:true,//启用cookie以允许服务器访问会话
xfbml:true//解析xfbml
});
};
//异步加载SDK
(职能(d){
var js,id='facebook jssdk';if(d.getElementById(id)){return;}
js=d.createElement('script');js.id=id;js.async=true;
js.src=“//connect.facebook.net/en_US/all.js”;
d、 getElementsByTagName('head')[0].appendChild(js);
}(文件);
填充饼干
在您的源代码中,我看不到您对用户进行身份验证的任何地方。用户必须首先授权您的应用程序,如下所述: