Facebook requests 2.0 , how to change “Accept” button url to be a url outside of facebook?

前端 未结 2 1438
囚心锁ツ
囚心锁ツ 2021-01-12 20:39

My app sits outside facebook canvas. The facebook request dialog 2.0 only redirects to canvas url eg. apps.ibibo.com/YOURAPP. How can I make it open a custom ur

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-12 20:56

    Need a jquery script to override the default function of facebook. However this works only when the person goes to "http://apps.facebook.com/mygame" and click on 'add app'.

    Simpler to just have a welcome page, users click on "PLAY" and it opens a new window into your page.

    Read more: http://developers.facebook.com/blog/post/525/ - good luck coding!

    Put somewhere on mygame page and add this javascript code:

    function updateButton(response) {
      //Log.info('Updating Button', response);
      var button = document.getElementById('fb-auth');
    
      if (response.status === 'connected') {
          //button.innerHTML = 'Logout';
          button.onclick = function() {
            FB.logout(function(response) {
              //Log.info('FB.logout callback', response);
            });
          };
        } else {
          //button.innerHTML = 'Login';
          button.onclick = function() {
            FB.login(function(response) {
              //Log.info('FB.login callback', response);
              if (response.status === 'connected') {
                //Log.info('User is logged in');
                window.open("http://xxxxxxxxxxxxxxxx/some.html");
              } else {
                //Log.info('User is logged out');
              }
            });
          };
        }
    };
    
    // run it once with the current status and also whenever the status changes
    FB.getLoginStatus(updateButton);
    FB.Event.subscribe('auth.statusChange', updateButton);
    

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题