Last active
August 29, 2015 14:02
-
-
Save MaxPleaner/d2043e9b9960626104ff to your computer and use it in GitHub Desktop.
Twitter client (broken)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json' | |
require 'simple_oauth' | |
require 'excon' | |
require 'nokogiri' | |
require_relative 'lib/twitter_creds' | |
def post_tweet(string) | |
authorization_header = SimpleOAuth::Header.new("post", | |
"https://api.twitter.com/1.1/statuses/user_timeline.json", | |
{ :screen_name => "ugly_name", | |
:text => string }, | |
{ :consumer_key => API_KEY, | |
:consumer_secret => API_SECRET, | |
:token => ACCESS_TOKEN, | |
:token_secret => ACCESS_TOKEN_SECRET }) | |
response = Excon.send("post", "https://api.twitter.com/1.1/statuses/user_timeline.json", { | |
:query => { :screen_name => "macsplean", | |
:text => string }, | |
:headers => { "Authorization" => authorization_header.to_s } | |
}) | |
puts response.body | |
puts response.status | |
end | |
if __FILE__ == $0 | |
post_tweet("asjdmnaskd") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's what I get when I run this:
max@max-INVALID twitter-client $ ruby scratch.rb
{"errors":[{"message":"Could not authenticate you","code":32}]}
401