最近开发推特api,走了不少的弯路。
我遇到一个api一直提示
{ "title": "Forbidden", "type": "about:blank", "status": 403, "detail": "Forbidden" }
直到刚才才解决这个bug。
这是因为申请的令牌是有权限的。
比如
这个请求
GET /2/tweets/:id/liking_users
他需要的权限有
tweet.read
users.read
like.read
这3个如果你申请令牌的时候没有写入这3个权限就会报这个错误。
在官网查询的是
该方法收到的令牌应被缓存。如果尝试过于频繁,请求将被拒绝,并出现 HTTP 403 错误代码 99。
Tokens received by this method should be cached. If attempted too frequently, requests will be rejected with a HTTP 403 with code 99.
和这个权限半毛钱关系没有。
附带一个简单的python代码。虽然我做的是web。
贴出这个代码供大家参考
import requests
from urllib.parse import urlencode
import base64
import hashlib
impo