我希望使用 lovoo API,但是不知道如何开始。通过查尔斯代理和查看流量,我得出了以下结论:
首先,一旦用户通过应用程序(iPhone)登录,就会向 https://api.lovoo.com/oauth/requestToken?
发送 GET
:
GET /oauth/requestToken? HTTP/1.1
Host api.lovoo.com
User-Agent LOVOO/612 (iPhone; iOS 10.2; Scale/3.00)
kissapi-app-idfv 1EC7A8E5-DF16-4E14-8EC9-98DD4772F903
tz Europe/xxx
kissapi-device-model iPhone 6s Plus
kissapi-app-version 3.17.0
kissapi-new-oauth 1
kissapi-device iphone
kissapi-app lovoo
wifi true
kissapi-adv-id 00000000-0000-0000-0000-000000000000
Connection keep-alive
kissapi-app-id 7F947A460DAFCA88556B2F35A6D78A3E
Authorization OAuth oauth_callback="oob", oauth_consumer_key="an.email%40gmail.com", oauth_nonce="A32CCA91-FB7A-4AA3-8314-0A9A6E67045E", oauth_signature="Sq8KTg%2FhVIGBaWgWXprPluczOs4%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1487017515", oauth_version="1.0"
Accept-Language en-CH;q=1, de-CH;q=0.9
kissapi-adv-on false
kissapi-version 1.20.0
kissapi-update-user-hash 6ea2bd15ea41d0dc8c2615589e2d52ec
Accept */*
kissapi-device-os 10.2
Accept-Encoding gzip, deflate
kissapi-sync-enabled 1
这也给出了以下标记: oauth_token=44d83e8ef50f&oauth_token_secret=37998f6c6ef2e618
接着是另一个 GET
到 https://api.lovoo.com/oauth/accessToken?
:
GET /oauth/accessToken? HTTP/1.1
Host api.lovoo.com
User-Agent LOVOO/612 (iPhone; iOS 10.2; Scale/3.00)
kissapi-app-idfv 1EC7A8E5-DF16-4E14-8EC9-98DD4772F903
tz Europe/xxx
kissapi-device-model iPhone 6s Plus
kissapi-app-version 3.17.0
kissapi-new-oauth 1
kissapi-device iphone
kissapi-app lovoo
wifi true
kissapi-adv-id 00000000-0000-0000-0000-000000000000
Connection keep-alive
kissapi-app-id 7F947A460DAFCA88556B2F35A6D78A3E
Authorization OAuth oauth_consumer_key="an.email%40gmail.com", oauth_nonce="080328C9-0A53-4971-85E7-65A43F12DC09", oauth_signature="Km0vd8xtHaQmRgkrGLsiljel13o%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1487017515", oauth_token="44d83e8ef50f", oauth_version="1.0"
Accept-Language en-CH;q=1, de-CH;q=0.9
kissapi-adv-on false
kissapi-version 1.20.0
kissapi-update-user-hash 6ea2bd15ea41d0dc8c2615589e2d52ec
Accept */*
kissapi-device-os 10.2
Accept-Encoding gzip, deflate
kissapi-sync-enabled 1
并提供以下标记: oauth_token=60c8977c8fe9509f&oauth_token_secret=549619c0ef4c4be7d7cb898e
现在,可以向 https://api.lovoo.com/init
提出请求:
GET /init HTTP/1.1
Host api.lovoo.com
User-Agent LOVOO/612 (iPhone; iOS 10.2; Scale/3.00)
kissapi-app-idfv 1EC7A8E5-DF16-4E14-8EC9-98DD4772F903
tz Europe/xxx
kissapi-device-model iPhone 6s Plus
kissapi-app-version 3.17.0
kissapi-new-oauth 1
kissapi-device iphone
kissapi-app lovoo
wifi true
kissapi-adv-id 00000000-0000-0000-0000-000000000000
Connection keep-alive
kissapi-app-id 7F947A460DAFCA88556B2F35A6D78A3E
Authorization OAuth oauth_consumer_key="an.email%40gmail.com", oauth_nonce="B622CE9C-DA3D-435C-939A-C58B83DBE85C", oauth_signature="0irvAsilrrdCCdLfu%2F0XSj7THlc%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1487017515", oauth_token="60c8977c8fe9509f", oauth_version="1.0"
Accept-Language en-CH;q=1, de-CH;q=0.9
kissapi-adv-on false
kissapi-version 1.20.0
kissapi-update-user-hash 6ea2bd15ea41d0dc8c2615589e2d52ec
Accept */*
kissapi-device-os 10.2
Accept-Encoding gzip, deflate
kissapi-sync-enabled 1
这些是我捕获的头,但是我不知道如何发送它们并使 Oauth
身份验证工作,特别是使用 oauth_nonce
。
Request-oauthlib 似乎支持它,但我不知道哪个标记对应哪个变量:
from requests_oauthlib import OAuth1Session
lovoo = OAuth1Session(
'client_key',
client_secret='client_secret',
resource_owner_key='resource_owner_key',
resource_owner_secret='resource_owner_secret'
)
url = 'https://api.lovoo.com/init'
r = lovoo.get(url)