# Twitter script since oAuth

**URL:** <https://rubytalk.org/t/twitter-script-since-oauth/60094>\
**Category:** ruby-talk\
**Created:** [17 September 2010 04:46 UTC](https://rubytalk.org/t/twitter-script-since-oauth/60094 "2010-09-17T04:46:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeff\_Greelish](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@Jeff\_Greelish](https://rubytalk.org/u/Jeff_Greelish)\
**Post date:** [17 September 2010 04:46 UTC](https://rubytalk.org/t/twitter-script-since-oauth/60094/1 "2010-09-17T04:46:23Z")

</div>

I had a script working with basic authinecation pulling from out local  
database and sending updates to twitter, about 12 a month. Not any  
crazy traffic. Since Aug 31st they turned off basic authineciton. Ive  
tried to implement the follow and it appears to work (pulls back a json  
file per the example. Tested this by puts the line to the screen.

I can not, figure out how to post an update to it. Im fairly new (well  
not new, but dont do it full time) to programming and I must be missing  
something.

Here is the script I am following. Bottom of page for the ruby script,  
just cant figure out how to pst an update to the timeline.  
[code]  
# Exchange your oauth\_token and oauth\_token\_secret for an AccessToken  
instance.  
def prepare\_access\_token(oauth\_token, oauth\_token\_secret)  
&nbsp;&nbsp;consumer = OAuth::Consumer.new("APIKey", "APISecret",  
&nbsp;&nbsp;&nbsp;&nbsp;{ :site =\> "[http://api.twitter.com](http://api.twitter.com)",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:scheme =\> :header  
&nbsp;&nbsp;&nbsp;&nbsp;})  
&nbsp;&nbsp;# now create the access token object from passed values  
&nbsp;&nbsp;token\_hash = { :oauth\_token =\> oauth\_token,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:oauth\_token\_secret =\> oauth\_token\_secret  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
&nbsp;&nbsp;access\_token = OAuth::AccessToken.from\_hash(consumer, token\_hash )  
&nbsp;&nbsp;return access\_token  
end

# Exchange our oauth\_token and oauth\_token secret for the AccessToken  
instance.  
access\_token = prepare\_access\_token("abcdefg", "hijklmnop")  
# use the access token as an agent to get the home timeline  
response = access\_token.request(:get,  
"[http://api.twitter.com/1/statuses/home\_timeline.json](http://api.twitter.com/1/statuses/home_timeline.json)")  
[/code]

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Skim\_Skim](https://avatars.discourse-cdn.com/v4/letter/s/8797f3/32.png) [@Skim\_Skim](https://rubytalk.org/u/Skim_Skim)\
**Post date:** [17 September 2010 05:06 UTC](https://rubytalk.org/t/twitter-script-since-oauth/60094/2 "2010-09-17T05:06:16Z")

</div>

You can use the twitter gem to post once you have the oauth token or even  
look at this gem that does both [GitHub - moomerman/twitter\_oauth: 🚫 DEPRECATED - Use https://github.com/sferik/twitter](http://github.com/moomerman/twitter_oauth)

> **···**
>
> On Thu, Sep 16, 2010 at 23:46, Jeff Greelish \<jeff.greelish@gmail.com\>wrote:
> 
> > I had a script working with basic authinecation pulling from out local  
> > database and sending updates to twitter, about 12 a month. Not any  
> > crazy traffic. Since Aug 31st they turned off basic authineciton. Ive  
> > tried to implement the follow and it appears to work (pulls back a json  
> > file per the example. Tested this by puts the line to the screen.
> > 
> > I can not, figure out how to post an update to it. Im fairly new (well  
> > not new, but dont do it full time) to programming and I must be missing  
> > something.
> > 
> > Here is the script I am following. Bottom of page for the ruby script,  
> > just cant figure out how to pst an update to the timeline.  
> > [code]  
> > # Exchange your oauth\_token and oauth\_token\_secret for an AccessToken  
> > instance.  
> > def prepare\_access\_token(oauth\_token, oauth\_token\_secret)  
> > consumer = OAuth::Consumer.new("APIKey", "APISecret",  
> > &nbsp;&nbsp;&nbsp;{ :site =\> "[http://api.twitter.com](http://api.twitter.com)",  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:scheme =\> :header  
> > &nbsp;&nbsp;&nbsp;})  
> > # now create the access token object from passed values  
> > token\_hash = { :oauth\_token =\> oauth\_token,  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:oauth\_token\_secret =\> oauth\_token\_secret  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
> > access\_token = OAuth::AccessToken.from\_hash(consumer, token\_hash )  
> > return access\_token  
> > end
> > 
> > # Exchange our oauth\_token and oauth\_token secret for the AccessToken  
> > instance.  
> > access\_token = prepare\_access\_token("abcdefg", "hijklmnop")  
> > # use the access token as an agent to get the home timeline  
> > response = access\_token.request(:get,  
> > "[http://api.twitter.com/1/statuses/home\_timeline.json&quot;\](http://api.twitter.com/1/statuses/home_timeline.json&quot;%5C))  
> > [/code]  
> > --  
> > Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).
