我正在尝试使用Twitter API中的verify_credentials endpoint。我想将include_entities
参数设置为false
。我能够使用第一个示例进行身份验证(因此我知道我的oauth_options
值是正确的),但如果我尝试设置include_entities参数,则会收到此错误{"code"=>32, "message"=>"Could not authenticate you."}
。注意:我不能使用Twitter gem。
WORKS:
response = HTTParty.get("https://api.twitter.com/1.1/account/verify_credentials.json", headers: {"Authorization" => oauth_options})
不工作:
response = HTTParty.get("https://api.twitter.com/1.1/account/verify_credentials.json", headers: {"Authorization" => oauth_options}, query: {include_entities: false})
也不起作用
response = HTTParty.get("https://api.twitter.com/1.1/account/verify_credentials.json?include_entities=false", headers: {"Authorization" => oauth_options})
答案 0 :(得分:0)
确保调整计算授权令牌的逻辑,因为它需要考虑查询参数。
阅读此处的文档https://dev.twitter.com/oauth/overview/authorizing-requests或使用自动处理它的库。
如果您正确签署请求,我可以确认它是否有效
$ oksocial 'https://api.twitter.com/1.1/account/verify_credentials.json?include_entities=false' | jq .
{
"id": 111,
"id_str": "111",
"name": "Fred Blogs",