使用 Java 脚本 SDK 的 Facebook API 发布操作
Facebook API Publishing action with Java script sdk
我真的很努力使用facebook api。A 创建了一个应用程序,一个对象是一个操作,我想测试在我的流中发布,(我知道公开发布必须得到 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: http://ogp.me/ns# subhinajjar:
http://ogp.me/ns/apps/subhinajjar#">
<title>OG Tutorial App</title>
<meta property="fb:app_id" content="452488354765730" />
<meta property="og:type" content="subhinajjar:article" />
<meta property="og:title" content="3eesho" />
<meta property="og:image" content="https://3eesho.com/public/admin/logo.png" />
<meta property="og:description" content="3eesho reading club" />
<meta property="og:url" content="https://3eesho.com/">
<script type="text/javascript">
function postreads()
{
FB.api(
'/me/subhinajjar:read?article',
'post',
{ article: 'https://3eesho.com/articles/2346/-' },
function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('read was successful! Action ID: ' + response.id);
}
});
}
</script>
</head>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '452488354765730', // 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="3eesho reading club"
src="https://3eesho.com/public/admin/logo.png"
width="550"/>
</p>
<br>
<form>
<input type="button" value="read" onclick="postreads()" />
</form>
<fb:activity actions="subhinajjar:read"></fb:activity>
</body>
</html>
但我总是有这样的信息:错误协议。 这让我发疯.我希望如果有人可以修改这段代码给我。
尝试将 FB.api
中 API 调用的 URL 更改为:'/me/subhinajjar:read'
(即删除文章,因为无论如何您都会将其作为数据发布)。
在response
块中,提醒错误以查看将操作发布到 Facebook 时实际发生的情况。您的代码应如下所示:
function postreads()
{
FB.api(
'/me/subhinajjar:read',
'post',
{ article: 'https://3eesho.com/articles/2346/-' },
function(response) {
if (!response || response.error) {
// show the error
alert( response.error );
} else {
alert('read was successful! Action ID: ' + response.id);
}
});
}
如果这不起作用,请尝试使用内置读取操作:
FB.api(
'/me/news.reads',
'post',
{ article: 'https://3eesho.com/articles/2346/-' },
function(response) {
if (!response || response.error) {
// show the error
alert( response.error );
} else {
alert('read was successful! Action ID: ' + response.id);
}
});
}
相关文章:
- 如何使jQuery插件函数可调用以供独立使用,而不在集合上操作
- Jquery菜单操作不稳定,定位不正确,存在一般错误
- 如何确定javascript已经完成了某些操作.ios上的
- 防止Alt+Shift默认操作或检测多种操作系统语言的Javascript
- 从JavaScript访问struts操作中的属性
- fluxxor向一个flux实例添加一组以上的操作
- Jquery表单验证插件-如果选中复选框,如何在提交时执行某些操作
- 操作放置在画布上的元素之间的连接
- 使用“+="操作人员
- Rails操作只调用一次,但我在ajax中每秒钟都调用一次
- Jquery未定义函数正在停止其他操作
- 如何操作iframe之外的元素
- javascript对象操作:根据指定条件选择属性
- jQuery:暂停按钮可以暂停所有其他操作
- 用于选择/文本框操作的JavaScript
- Google 脚本:用于创建日历活动的脚本运行时不会出错,但不会执行任何操作
- 通过javascript操作图像,非常简单
- 将文本框中的值用于按钮窗体操作上的变量
- 当通过AJAX调用时,控制器操作不会执行
- 操作javascript变量[HTML]以只显示文本