문제

I'm trying to connect to Twitter's REST API using application-only authentication. I get the bearer token, but the GET request doesn't work.

token = TOKEN
response = RestClient.get "https://api.twitter.com/1.1/followers/ids.json?screen_name=twitter", {headers: {'Authorization' => "Bearer #{token}"}}

Am I doing something incorrect with rest-client?

도움이 되었습니까?

해결책

You don't need the "headers"-key. Since the hash after the URL is for headers your request will contain a header with the name "headers" rather than "Authoriziation".

It should work by just removing "headers":

RestClient.get "https://api.twitter.com/1.1/followers/ids.json?screen_name=twitter", {'Authorization' => "Bearer #{token}"} 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top