Periscope API中的Twitter登录POST请求

时间:2015-08-06 11:37:59

标签: api twitter-oauth

我正在尝试在我的应用程序中使用Periscope API(https://github.com/gabrielg/periscope_api/blob/master/API.md)。在API链接中,我尝试向https://api.periscope.tv/api/v2/loginTwitter?build=v1.0.2发送POST请求 请求正文如下

{
    "bundle_id": "com.bountylabs.periscope",
    "phone_number": "",
    "session_key": "<twitter_user_oauth_key>",
    "session_secret": "<twitter_user_oauth_secret>",
    "user_id": "<twitter_user_id>",
    "user_name": "<twitter_user_name>",
    "vendor_id": "81EA8A9B-2950-40CD-9365-40535404DDE4"
}

我已经在https://apps.twitter.com/中有一个应用程序,但我不知道如何使用twitter_user_oauth_key和twitter_user_oauth_secret。你能帮忙吗?

2 个答案:

答案 0 :(得分:3)

我必须说https://github.com/gabrielg/periscope_api/实现有点复杂。当您实际只需要一个密钥来访问API时,作者使用2组密钥(IOS_ *和PERISCOPE_ *)。我没有尝试广播,但在我的PHP库中,所有其他功能都可以毫无困难地工作,只有他称之为PERISCOPE_ *键组。

在以Periscope应用程序访问它之后,您将从Twitter获得session_secretsession_key

所以Periscope通过Twitter流程登录就像

  1. 通过https://api.twitter.com/oauth/request_token
  2. 申请OAuth令牌
  3. 将用户重定向到https://api.twitter.com/oauth/authorize?oauth_token=[oauth_token]
  4. 等待用户登录并从重定向网址
  5. 获取oauth_tokenoauth_verifier
  6. 通过https://api.twitter.com/oauth/access_token?oauth_verifier=[oauth_verifier]
  7. 请求获取oauth_tokenoauth_token_secretuser_iduser_name
  8. https://api.periscope.tv/api/v2/loginTwitter发送请求

      {
        "bundle_id": "com.bountylabs.periscope",
        "phone_number": "",
        "session_key": "oauth_token",
        "session_secret": "oauth_token_secret",
        "user_id": "user_id",
        "user_name": "user_name",
        "vendor_id": "81EA8A9B-2950-40CD-9365-40535404DDE4"
      }
    
  9. 保存上次回复的cookie值,并将其作为某种身份验证令牌添加到所有JSON API调用中。
  10. 1和4步骤中的请求应使用正确的Authorization标头进行签名,该标头需要Periscope应用程序的consumer_keyconsumer_secret。虽然consumer_key可以在第一步中被嗅探(如果您能够绕过证书固定),consumer_secret永远不会离开您的设备而您无法通过简单的流量拦截来获取它。

    有登录过程https://gist.github.com/bearburger/b4d1a058c4f85b75fa83

    的PHP示例

答案 1 :(得分:0)

Periscope的API不公开,你所指的库是一种黑客攻击。

要回答原始问题,oauth_key&amp; oauth_secret是您的实际设备发送给潜望镜服务的密钥。您可以通过嗅探设备发送的网络流量来找到它们。