【问题标题】:How do I setup hello.js to access Twitter?如何设置 hello.js 以访问 Twitter?
【发布时间】:2015-02-22 21:55:52
【问题描述】:

我正在尝试编写一个简单的 Javascript 页面,用于使用 Hello.js 发送带有图片的推文。我以this demo 为起点,但很多内容并没有得到真正的解释。我的初始化看起来像这样:

hello.init({
    'twitter' : '****'
});

上面写着here 我需要“在 OAuth 代理服务上注册您的 client_id + client_secret”。但是我该怎么做呢?我的应用的 Twitter 页面显示:

  1. 消费者密钥。
  2. 消费者秘密。
  3. 访问令牌。
  4. 访问令牌秘密。

https://auth-server.herokuapp.com/注册要求:

  1. 参考。
  2. 域。
  3. client_id.
  4. client_secret.

我将这些设置为什么?引用和域是否必须与我的代码中的某些内容相匹配? client_id 和 client_secret 是 Consumer 还是 Access Token 参数?

【问题讨论】:

    标签: twitter hello.js


    【解决方案1】:

    引用是网络名称,如“twitter”、“dropbox”等。

    域是您调用的域。它可以与“http://localhost:8080”之类的东西一起使用。

    对于 Twitter,client_id 是 Consumer Key (API Key),client_secret 是 Consumer Secret (API Secret)。

    完成此操作后,您只需在 JS 代码中添加如下内容:

      hello.init({
        twitter: '<your Consumer Key>'
      }, {});
    

    然后带有以下代码的按钮应该可以工作:

    <button onclick="hello( 'twitter' ).login()">Login with Twitter</button>
    

    【讨论】:

      【解决方案2】:

      我在使用 hello.js 和 Twitter 时遇到了很多问题,直到我终于发现:

      • 如果您还没有工作域(您正在开发),您应该在twitter app 的设置中的回调 URL 中写入 127.0.0.1。

      -在相同的设置中,确保选择“允许应用注册 twitter”。

      -你的初始化函数应该是这样的:

      hello.init({
          twitter : 'xxxxxx'
       },{redirect_uri : 'localhost',
           oauth_proxy : 'https://auth-server.herokuapp.com',
            oauth_version: 'xx' // probably 1.0a with hello.js
      });
      

      【讨论】:

      • 它将验证您的(在这种情况下)Twitter API 密钥的服务器。
      • @NatiKrisi auth-server.herokuapp.com 是 hello.js 开发者运行的 OAuth 代理服务器
      猜你喜欢
      • 2013-10-09
      • 1970-01-01
      • 2021-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-20
      • 2016-02-17
      相关资源
      最近更新 更多