Pandora Api auth.partner登录出现错误 [英] Pandora Api auth.partnerLogin giving error

查看:140
本文介绍了Pandora Api auth.partner登录出现错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近偶然发现了有关非官方Pandora API的一些文档.

我决定尝试使用Python 3.

I decided to try this with Python 3.

转到身份验证"页面后,我发现我首先必须进行验证该服务可在我的国家/地区使用,所以我做到了.

After heading to the Authentication page I saw that I first had to verfiy that the service was available in my country so I did this.

import requests
import urllib

url = "http://internal-tuner.pandora.com/services/json/?method=test.checkLicensing"

res = requests.post(url)

print(res.status_code)
print(res.content)

它打印出来:

<Response [200]>
b'{"stat":"ok","result":{"isAllowed":true}}'

对.因此,我可以使用合作伙伴服务.

Right. So I'm allowed to use the partner service.

接下来,我看到我必须获得合作伙伴登录.

Next I saw that I had to get a Partner Login.

所以我从合作伙伴页面.

username = "android"
password = "AC7IBG09A3DTSYM4R41UJWL07VLN8JI7"
deviceModel = "android-generic"

接下来,该文档说要发送发帖请求到以下链接之一作为 base 网址:

Next, the documentation says to send a post request to one of the following links as the base url:

  • http://tuner.pandora.com/services/json/
  • https://tuner.pandora.com/services/json/
  • http://internal-tuner.pandora.com/services/json/
  • https://internal-tuner.pandora.com/services/json/

现在可以对url参数进行编码,并将其放在基本url之后. 它说我应该使用上面的usernamepassworddeviceModel,我要调用的方法(对于合作伙伴登录,它说它是"auth.PartnerLogin",以及版本(它说来传递字符串"5)并对其进行网址编码.

Now to encode the url parameters and put them after the base url. It says I should take the above username, password, deviceModel, the method I want to call (for partner login it says it is "auth.PartnerLogin", and the version (it says pass in the string "5") and url encode them.

因此,我以urlencoded格式设置了url参数并触发了POST请求:

So I set up the url params in urlencoded format and fire off a POST request:

import requests
import urllib

url = "http://internal-tuner.pandora.com/services/json/?"

username = "android"
password = "AC7IBG09A3DTSYM4R41UJWL07VLN8JI7"
deviceModel = "android-generic"

data = {
    "method": "auth.partnerLogin",
    "username": username,
    "password": password,
    "deviceModel": deviceModel,
    "version": "5"
}

url += urllib.parse.urlencode(data)

res = requests.post(url)

print("url:", url)
print("response:", res)
print("content:", res.content)

但是当我这样做时,它会打印出来并告诉我有一个错误:

But when I do it prints this out and tells me there was an error:

url: http://internal-tuner.pandora.com/services/json/?method=auth.partnerLogin&username=android&password=AC7IBG09A3DTSYM4R41UJWL07VLN8JI7&deviceModel=android-generic&version=5
response: <Response [200]>
content: b'{"stat":"fail","message":"An unexpected error occurred","code":9}'

以前有人使用过此Api吗? 为什么会出现错误?我在这里想念什么吗? 显然, pithos 使用此api,它可以很好地加载音乐.

Has anyone else used this Api before? Why am I getting an error? Am I missing something here? Apparently pithos uses this api, and it is loading music fine for me.

有人可以在这里向我指出正确的方向吗?

Can anybody point me in the right direction here please?

推荐答案

就像您将数据作为参数传递并使用错误的url.

Looks like you passing data as parameters and using incorrect url.

正确的卷曲请求:

########## REQUEST ##########
curl  -i  --data '{ "username": "android", "password": "AC7IBG09A3DTSYM4R41UJWL07VLN8JI7", "deviceModel": "android-generic", "version": "5", "includeUrls": true }' -X POST 'https://tuner.pandora.com:443/services/json/?method=auth.partnerLogin'   -H "Content-Type: application/json"  -A 'pinobar'
########## OUTPUT ##########
HTTP/1.1 200 OK
Date: Thu, 04 Jan 2018 03:46:54 GMT
Server: Apache
Content-Type: text/plain; charset=utf-8
Content-Length: 741
Cache-Control: must-revalidate, max-age=0
Expires: -1
Vary: Accept-Encoding

{"stat":"ok","result":{"syncTime":"f6f071bb4b886bc3545fbd66701b8d38","deviceProperties":{"followOnAdRefreshInterval":3,"ooyala":{"streamingPercentage":0,"streamingWhitelist":[534051315],"videoAdBufferRetryCount":3,"videoAdLoadingTimeout":2,"videoAdPlayTimeout":8},"videoAdUniqueInterval":0,"videoAdStartInterval":180,"optionalFeatures":{"optionalFeature":[{"feature":"useAudioProxy2","enabled":"false","platformVersionRange":{"low":"4.0","high":"5.0.0"},"productVersionRange":{"low":"1.6","high":"*"}}]},"adRefreshInterval":3,"videoAdRefreshInterval":870},"partnerAuthToken":"VADEjNzUq9Ew9HUkIzUT489kVe9kjo0If3","partnerId":"42","stationSkipUnit":"hour","urls":{"autoComplete":"http://autocomplete.pandora.com/search"},"stationSkipLimit":6}}

我建议使用 urllib2示例.

以下是我们案例的工作示例:

Here working sample for our case:

import json
import urllib2

username    = "android"
password    = "AC7IBG09A3DTSYM4R41UJWL07VLN8JI7"
deviceModel = "android-generic"
url         = "https://tuner.pandora.com:443/services/json/?method=auth.partnerLogin"

values = {
    "username"   : username,
    "password"   : password,
    "deviceModel": deviceModel,
    "version"    : "5"
}

data = json.dumps(values)
headers = {'content-type': 'application/json'}
req = urllib2.Request(url, data, headers)
response = urllib2.urlopen(req)
content = response.read()

print("data:", data)
print("url:", url)
print("response:", response)
print("content:", content)

输出:

('url:', 'https://tuner.pandora.com:443/services/json/?method=auth.partnerLogin')
('response:', <addinfourl at 4509594832 whose fp = <socket._fileobject object at 0x10c7c0bd0>>)
('content:', '{"stat":"ok","result":{"stationSkipLimit":6,"partnerId":"42","partnerAuthToken":"VAEIniGnwSV1exsWHgUcsQgV5HA63B1nFA","syncTime":"4663310634ae885f45f489b2ab918a66","deviceProperties":{"followOnAdRefreshInterval":3,"ooyala":{"streamingPercentage":0,"streamingWhitelist":[534051315],"videoAdBufferRetryCount":3,"videoAdLoadingTimeout":2,"videoAdPlayTimeout":8},"videoAdUniqueInterval":0,"videoAdStartInterval":180,"optionalFeatures":{"optionalFeature":[{"feature":"useAudioProxy2","enabled":"false","platformVersionRange":{"low":"4.0","high":"5.0.0"},"productVersionRange":{"low":"1.6","high":"*"}}]},"adRefreshInterval":3,"videoAdRefreshInterval":870},"stationSkipUnit":"hour"}}')

这篇关于Pandora Api auth.partner登录出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆