在过去八个小时左右的时间里,我一直在不知疲倦地工作,试图以一种方式格式化我的 Wordpress 博客,这意味着用户可以通过使用 Article 的 Open Graph 设置来单击按钮并将文章发布到股票行情。
我一直在使用这里找到的教程。
不幸的是,我无法完成它,因为每次单击我创建的“发布”按钮时,都会弹出一条错误消息。
使用 Facebook 的调试器时,我没有发现任何问题,并且所有必要的标签都已到位(我有一个插件可以为我做这件事,非常完美)。
以下是我对header.php
文件所做的更改以适应本教程:
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"
xmlns:fb="https://www.facebook.com/2008/fbml">
之前添加了以下内容</head>
:
<script type="text/javascript">
function postArticle()
{
FB.api(
'/me/[NAMESPACE]:read?Article=<?php get_permalink() ?>',
'post',
function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Successful! Action ID: ' + response.id);
}
});
}
</script>
清楚地放置了一个请求权限的登录按钮:
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '[APPLICATION 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>
<fb:login-button perms="email,publish_actions,user_actions.news">
Login with Facebook
</fb:login-button>
最后将以下内容放在页面上我希望按钮出现的位置:
<fb:add-to-timeline></fb:add-to-timeline>
<form>
<input type="button" value="Publish" onclick="postArticle()" />
</form>
在我的 Open Graph 设置中,我有操作类型“读取”以及对象类型“文章”。
为什么这对我不起作用?