所以,我玩弄(从零售商店包含提供丹麦目录)Etilbudsavis' API(与使用Python的API播放)。 我的目标是获取基于搜索查询数据。 the API acutally allows this,开箱即用。但是,当我尝试这样做时,最终出现错误,说我的令牌丢失了。不管怎么说,这里是我的代码:为什么我会遇到这个错误 - “缺少令牌”?
from urllib2 import urlopen
from json import load
import requests
body = {'api_key': 'secret_api_key'}
response = requests.post('https://api.etilbudsavis.dk/v2/sessions', data=body)
print response.text
new_body = {'_token:': 'token_obtained_from_POST_method', 'query:': 'coca-cola'}
new_response = requests.get('https://api.etilbudsavis.dk/v2/offers/search', data=new_body)
print new_response.text
完整的错误:
{"code":1107,"id":"00ilpgq7etum2ksrh4nr6y1jlu5ng8cj","message":"missing token","
details":"Missing token\nNo token found in request to an endpoint that requires
a valid token.","previous":null,"@note.1":"Hey! It looks like you found an error
. If you have any questions about this error, feel free to contact support with
the above error id."}
现在,我收到一个新的错误:“{”code“:1106,”id“:”00ilpnqbe2jeoxcnyejlh75vaho2c3jq“,”message“:”No Origin“,”deta ils“:”Missing origin header \ nThis token “:空,” @注1“:”不能没有有效的产地^ h EADER“”以前的使用。嘿,它看起来就像你发现了一个错误如果你 有这个错误的任何问题,请随时联系支持与ABOV E错误ID。“}' – DBE7
看起来你需要签署令牌之前,你可以使用它,请参阅[他们的文档(http://docs.api.etilbudsavis.dk/docs/getting -started#API会话的签名)。 –
它说:“如果你的eTilbudsavis应用程序是由JavaScript在浏览器中不执行,您需要登录您的令牌,然后才能开始发送请求不要简单地增加一个Origin标!”。我不写手机应用程序或类似的东西。我应该没有签约... – DBE7