开发者

Logging my rails application's users into facebook through iframe display option hangs

This code does not work:

$(document).ready(function() {
        window.fbAsyncInit = function() {
            FB.init({appId: "<%= FACEBOOK_CONFIG['application_id'] %>", status: true, cook开发者_开发技巧ie: true,
                     xfbml: true});



                FB.ui(
                   {
                     method: 'oauth',
                    client_id: "<%= FACEBOOK_CONFIG['application_id'] %>",
                    scope: "<%= FACEBOOK_CONFIG['permissions'] %>",
                    state: "<%= secure_hash(FACEBOOK_CONFIG['secret_phrase']) %>"

                   },
                   function(response) {
                     if (response && response.post_id) {
                       alert('Post was published.');
                     } else {
                       alert('Post was not published.');
                     }
                   }
                     );
});

What am I doing wrong?


You've done the FB.init({appId: ..., xfbml: true}); bit first right?

I think the method you want to call is {method: 'oauth'} like:

        FB.ui({ method: 'oauth',
                client_id: <%= FACEBOOK_CONFIG['application_id'] %>,
                scope: '<%= FACEBOOK_CONFIG['permissions'] %>',
                state: '<%= secure_hash(FACEBOOK_CONFIG['secret_phrase']) %>'
              },
              function (response) {
                if (response && response.post_id) {
                  alert('success');
                } else {
                  alert('failure');
                }
              }
        );

Although, to just do a login it's easier to call:

FB.getLoginStatus(function(response) {
      if (response.session) { alert('success'); }
      else { alert('nope'); }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜