[英]Facebook app built in JavaScript SDK not posting to Timeline
我已经开发了一个Facebook应用程序/独立网站,该网站使用自定义对象和操作来支持利兹大学的开放日。 这是使用JavaScript SDK构建的。
这是URL- https://fbapps.leeds.ac.uk/opendays/recap.html
该代码可以正常工作并将其发布到Open Graph,但仅发布到该用户的个人资料,并且不会显示在时间轴上。
Facebook已经批准了我的明确共享请求,并且已在应用程序设置中启用了该请求,但是它似乎并没有像我期望的那样发布到用户时间轴上。
该帖子确实显示在“活动日志”中。
我已经在代码中添加了explict共享参数,更改了默认隐私设置,并在data_scope中启用了publish_actions。
没有人知道缺少什么,因为看不出问题所在吗?
非常感谢收到任何建议。 非常感谢任何人可以提供的任何帮助。
这是代码:
<script type="text/javascript">
// You probably don't want to use globals, but this is just example code
var fbAppId = '1471972309703879';
var objectToLike = 'https://fbapps.leeds.ac.uk/recap.html';
/*
* This is boilerplate code that is used to initialize
* the Facebook JS SDK. You would normally set your
* App ID in this code.
*/
// Additional JS functions here
window.fbAsyncInit = function() {
FB.init({
appId : 1471972309703879, // App ID
status : true, // check login status
cookie : true, // enable cookies to allow the
// server to access the session
xfbml : true, // parse page for xfbml or html5
// social plugins like login button below
version : 'v2.0', // Specify an API version
});
// Put additional init code here
};
// Load the SDK Asynchronously
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
/*
* This function makes a call to the og.likes API. The
* object argument is the object you like. Other types
* of APIs may take other arguments. (i.e. the book.reads
* API takes a book= argument.)
*
* Because it's a sample, it also sets the privacy
* parameter so that it will create a story that only you
* can see. Remove the privacy parameter and the story
* will be visible to whatever the default privacy was when
* you added the app.
*
* Also note that you can view any story with the id, as
* demonstrated with the code below.
*
* APIs used in postLike():
* Call the Graph API from JS:
* https://developers.facebook.com/docs/reference/javascript/FB.api
* The Open Graph og.likes API:
* https://developers.facebook.com/docs/reference/opengraph/action-type/og.likes
* Privacy argument:
* https://developers.facebook.com/docs/reference/api/privacy-parameter
*/
function postLike() {
FB.api(
'me/leedsopendaypics:enjoy',
'post',
{ recap: "https://fbapps.leeds.ac.uk/opendays/recap.html",
fb:explicitly_shared = "true",
privacy: {'value': 'EVERYONE'} },
function(response) {
if (!response) {
alert('Error occurred.');
} else if (response.error) {
document.getElementById('result').innerHTML =
'<h3>Please log in to Facebook above so you can share this page</h3>';
} else {
document.getElementById('result').innerHTML =
'<a href=\"https://www.facebook.com/me/activity/' +
response.id + '\" target="_parent">' +
'<h3>Thanks. That has now been shared.</h3></a>';
}
}
);
}
</script>
<!--
Login Button
https://developers.facebook.com/docs/reference/plugins/login
This example needs the 'publish_actions' permission in
order to publish an action. The scope parameter below
is what prompts the user for that permission.
-->
<div
class="fb-login-button"
data-show-faces="true"
data-width="200"
data-max-rows="1"
data-scope="publish_actions"
return_scopes="true">
</div>
<div>
<input
type="button"
class="button"
value="Share this recap page on your Facebook Timeline"
onclick="postLike();">
</div>
<div id="result"></div>
好吧,这就是Open Graph的好处:
未将开放图谱故事发布为状态 ,这是用户使用您的应用执行的一项活动。 因此,这些故事作为应用程序活动捆绑在一起,而不是在时间轴上发布状态并不必要地充斥时间轴。
因此,在时间轴中检查“ 近期活动”部分(向下滚动一下,您会发现)-
但请不要担心,这个故事会在您和您朋友的墙上 (无论您设置了哪种隐私设置)都以适当的大块分享。 要查看该故事在墙上的样子,您可以检查一下墙本身,但是如果您找不到它(墙上的帖子数量不多,可能很难找到一个)-
转到活动日志 ,然后点击时间-
这是该帖子的外观-
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.