简体   繁体   English

Genius API 搜索结果成功但没有命中

[英]Genius API Search result successful but no hits

When making a call to the Genius API (the music lyric service) search capability to search for a specific song by title, my GET request is successfully processed and returns a HTTP status code of 200, but the JSON response returns no hits for the song I searched.当调用 Genius API(音乐歌词服务)搜索功能按标题搜索特定歌曲时,我的 GET 请求已成功处理并返回 HTTP 状态代码 200,但 JSON 响应未返回歌曲的匹配项我搜索了。

{u'meta': {u'status': 200}, u'response': {u'hits': []}}

Notice the value for the hits key is an empty array.注意 hits 键的值是一个空数组。 This is strange, since when "testing" the same call on the Genius API Docs site https://docs.genius.com/#web_pages-h2 with the same OAuth2 access token I'm able to get 10 hits for the same search.这很奇怪,因为当使用相同的 OAuth2 访问令牌在 Genius API Docs 站点https://docs.genius.com/#web_pages-h2上“测试”相同的调用时,我能够为相同的搜索获得 10 次匹配. I've tried searching multiple song titles with the same results.我试过用相同的结果搜索多首歌曲。

I'm using Python 2.7.12, and I replaced my API call access token with AccessTOKEN below so I'm not sharing that publicly (though I was testing with the correct access token)我正在使用 Python 2.7.12,我用下面的 AccessTOKEN 替换了我的 API 调用访问令牌,所以我没有公开分享它(尽管我正在使用正确的访问令牌进行测试)

#!/usr/bin/env python
# -*- coding=utf-8 -*-
import requests

baseUrl = "http://api.genius.com"

headers = {'Authorization': 'Bearer AccessTOKEN'}
searchUrl = baseUrl + "/search"
songTitle = "Shelter"
data = {'q': songTitle}
response = requests.get(searchUrl, data=data, headers=headers)
json = response.json()
print json

Any ideas?有任何想法吗?

The data parameter is used for a POST request. data参数用于POST请求。 Since this is a GET request, you should pass your data to the params parameter.由于这是一个GET请求,您应该将data传递给params参数。

response = requests.get(searchUrl, params=data, headers=headers)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM