无法测试Facebook Open Graph操作
Cannot Test Facebook Open Graph Action
我正在尝试测试一个Open Graph Facebook操作,但我很难理解如何执行。我用这个视频开始:http://www.youtube.com/watch?v=8x6T7-WFSBg。当我试图运行代码(我已经粘贴在下面(时,它会给我一个错误。我想我应该测试一下,看看我是否通过http://graph.facebook.com/me/APP_NAME(当然,app_name被我的应用程序名称空间所取代(。不过我得到了这个错误:
{
"error": {
"message": "An active access token must be used to query information about the current user.",
"type": "OAuthException",
"code": 2500
}
}
我假设我不能测试我的操作的原因是因为没有活动的访问令牌?不过,我发现的问题是,我是该应用程序的管理员,所以我认为无论哪种方式,我都应该拥有该访问权限。
以下是(视频中(使用的代码,以便对Open Graph操作进行简单的基本测试。请注意,我已经将应用程序的信息替换为大写。感谢您的提前帮助,我是开放图的新手,只是想深入了解。也感谢您对我的耐心!
这是代码:
<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# fb: http://ogp.me/ns/fb# APP_NAMESPACE: http://ogp.me/ns/fb/APP_NAMESPACE#">
<meta property="fb:app_id" content="APP_ID" />
<meta property="og:type" content="APP_NAMESPACE:ACTION" />
<meta property="og:url" content="Put your own URL to the object here" />
<meta property="og:title" content="Sample ACTION" />
<meta property="og:image" content="https://fbstatic-a.akamaihd.net/images/devsite/attachment_blank.png" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
</head>
<body>
<input type="button" value="test" onclick="javascript:postAction('ACTION', 'OBJECT', 'URL OF THIS PAGE');" />
<script type="text/javascript">
function postAction( action, object_type, object_url ){
FB.api('/me/APP_NAMESPACE:' + action + '?' + object_type + '=' + object_url, 'post', function(response){
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post was successful! Action ID: ' + response.id);
}
});
}
</script>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'APP_ID', // 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>
</body>
</html>
您需要使用应用程序对用户进行身份验证查看此处了解更多信息:http://hayageek.com/facebook-dialog-oauth/或通过facebookdevhttp://developers.facebook.com/docs/concepts/login/
相关文章:
- 如何使jQuery插件函数可调用以供独立使用,而不在集合上操作
- Jquery菜单操作不稳定,定位不正确,存在一般错误
- 如何确定javascript已经完成了某些操作.ios上的
- 防止Alt+Shift默认操作或检测多种操作系统语言的Javascript
- 从JavaScript访问struts操作中的属性
- fluxxor向一个flux实例添加一组以上的操作
- Jquery表单验证插件-如果选中复选框,如何在提交时执行某些操作
- 操作放置在画布上的元素之间的连接
- 使用“+="操作人员
- Rails操作只调用一次,但我在ajax中每秒钟都调用一次
- Jquery未定义函数正在停止其他操作
- 如何操作iframe之外的元素
- javascript对象操作:根据指定条件选择属性
- jQuery:暂停按钮可以暂停所有其他操作
- 用于选择/文本框操作的JavaScript
- Google 脚本:用于创建日历活动的脚本运行时不会出错,但不会执行任何操作
- 通过javascript操作图像,非常简单
- 将文本框中的值用于按钮窗体操作上的变量
- Facebook Open Graph预操作验证
- 无法测试Facebook Open Graph操作