【问题标题】:Javascript function - FB oAuth function turn it for the twitter oAuth?Javascript 函数 - FB oAuth 函数转它为 twitter oAuth?
【发布时间】:2012-12-20 14:48:10
【问题描述】:

我实际上是在使用这个 js 函数来连接 facebook。

window.fbAsyncInit = function(){
   FB.init({ 
    appId: '371***********',
     status: true,
      cookie: true,
       xfbml: true ,
       oauth:true,
       channelUrl: '<?php echo base_url(); ?>fb-channel-file.php' //this domain
     });
};
(function() {
   var e = document.createElement('script');
   e.type = 'text/javascript';
   e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
   e.async = true;
   document.getElementById("fb-root").appendChild(e);
}());
// FB LOGIN -->

function FBlogin(){
  FB.getLoginStatus(function(r){
    FB.login(function(response) {
      if(response.authResponse) {
        $.ajax({
          type:'GET',
          url: _config_base_url+'/auth/ajax_login',
          dataType:'json',
          data:{'fb_at':response.authResponse.accessToken},
          beforeSend:function(){
            notify('Loading ...',false,'notify-info');
          },
          error:function(_response){
              notify('An error occurred, please try again later.',false); 

            },
            success:function(json){
              notify_destroy();

              window.location.href= _config_base_url+'/profile';

            }
          });
      } else {}
    },{scope:'email'/*,user_birthday,user_location*/});
  });
}

现在我想重现相同/完全相同的功能,允许人们通过Twitter 进行连接,我只是将其转为Google+, 但我真的不明白如何为Twitter oAuth.打开它

有什么想法吗?

【问题讨论】:

  • 您的 pastebin 链接已失效。
  • 无论如何我都会更新代码是我发布的这个

标签: javascript jquery ajax refactoring twitter-oauth


【解决方案1】:

更新

原答案

  • This answer 到 JavaScript OAuth sign in with Twitter 看起来由于安全原因,这是不可能或不是最好的方法。

    问题是任何查看您页面的人现在也可以查看 您的消费者密钥和秘密,必须保密。

    ...

    Twitter 确实声明必须尽一切可能保持这些 值 private 以避免这种情况发生

    很遗憾,目前无法在基于浏览器的浏览器中使用 oAuth JavaScript 安全。

  • jsOAuth 可能会有所帮助,但正如上面的答案所述,安全是一个问题。

    jsOAuth 是一个实现 OAuth 协议的 javascript 库。 jsOAuth 旨在形成自定义客户端的基础,例如 Twitter 和 雅虎。

    ...

    出于安全原因,jsOAuth 不在浏览器中运行。此处仅提及用于运行测试套件的浏览器。

【讨论】:

  • Twitter Javascript OAuth 即将弃用。更好地意识到这一点。
猜你喜欢
  • 1970-01-01
  • 2012-02-01
  • 1970-01-01
  • 2011-07-01
  • 2011-01-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多