Skip to content

Posting to Twitter automatically using OAuth

Twitter recently switched off basic HTTP authentication, forcing developers to use the more complex (but hopefully safer) OAuth. There are lots of OAuth examples out there, but they all seem to focus on interactive apps, where the user is sent to Twitter to authenticate, and then the app uses the resulting access token to post on the user’s behalf.

However, for FuncNet we have a simple script running in a cron job, which posts a status message to @FuncNet every so often. This runs without any supervision, so I was left scratching my head as to how I could obtain the access token and access token secret required to post. The app registration page at http://twitter.com/oauth_clients/details/NNNNNN for each app only shows its consumer key and consumer secret which are something different.

Eventually, thanks to Net::Twitter developer Marc Mims on this thread, I discovered that there’s a whole separate page for each app at http://dev.twitter.com/apps/NNNNNN/my_token which has the access token and access token secret required for the app to post to its own account.

N.B. In the URLs above, NNNNNN corresponds to the numeric ID for your application. If you don’t know what this is, just go to http://dev.twitter.com/apps, click on the app name to get the consumer strings, and then click on My Access Token to get the access strings.

Once you have these, you can post like this (thanks again to Marc for example):

    use Net::Twitter;
 
    my $nt = Net::Twitter->new(
        traits => [qw/OAuth API::REST/],
        consumer_key        => $YOUR_CONSUMER_KEY,
        consumer_secret     => $YOUR_CONSUMER_SECRET,
        access_token        => $YOUR_ACCESS_TOKEN,
        access_token_secret => $YOUR_ACCESS_SECRET,
    );
 
    $nt->update("Bob's your uncle!");

Why you need 4 distinct incomprehensible strings in order to post a single tweet, I don’t know, but presumably it’s justified on security grounds. What isn’t justified is Twitter hiding two of them somewhere else entirely, and not linking to that place from the main OAuth page for the app.

Not useful, guys.

UPDATE: It seems there are bigger problems with Twitter’s new process. This detailed ArsTechnica article describes OAuth 1.0a as “an inelegant hack” and Twitter’s implementation of it as being “against all reason”.

If you’re having trouble with it, you’re not alone; it seems almost designed to cause problems for app developers, and particularly open-source app developers. The article’s well worth a read.

Share/save this page:
  • email
  • Google Bookmarks
  • Twitter
  • FriendFeed
  • del.icio.us
  • Digg
  • Reddit
  • StumbleUpon
  • Technorati
  • DZone
  • Slashdot
  • Fark
  • Facebook
  • MySpace
  • LinkedIn
  • Live
  • connotea

{ 16 } Comments

  1. loi Malraux | August 5, 2013 at 8:30 pm | Permalink

    We absolutely love your blog and find a lot of your post’s to be exactly what I’m looking for.
    Would you offer guest writers to write content to suit your needs?
    I wouldn’t mind creating a post or elaborating on most of the subjects you write related to here. Again, awesome web log!

  2. imvu free staff | September 11, 2013 at 10:30 am | Permalink

    dating Arrange meeting a expected is beauteous fiance fro you proper after breaking up.
    The person recommends that everyone should give it a try
    as they have nothing to lose by registering a free account.

    However, now things have taken a revolutionary turn for the best.

  3. cost-free | September 13, 2013 at 7:15 pm | Permalink

    People everywhere ‘ regardless of their phone type ‘ have needs
    for communication and entertainment. 0 – Liive Football The best soccer leagues
    from around the world are followed in this app.

    The Droid, Verizon Wireless and Motorola’s answer to the i – Phone, was
    only recently released to the public, but already, the Android Market is loaded with hundreds of free apps.

  4. Get IMVU Credit | September 16, 2013 at 9:42 pm | Permalink

    Check out my other article about imvu or go to for
    more information. Many roleplayers opt to have families
    and get married in these virtual worlds as well.
    You can even design and decorate your own room to invite other users to.

  5. Sertalig | December 13, 2013 at 5:24 pm | Permalink

    viagra economico
    generic viagra
    online order lilly viagra
    – generic viagra

  6. internet. | January 24, 2014 at 9:46 am | Permalink

    If you aree going for best contents like me, only visit this site eery day
    for the reason that it provides feature contents, thanks

  7. womens issues | March 1, 2014 at 7:13 am | Permalink

    Hi there, its nice article regarding media print, we all be aware of media is a
    great source of facts.

  8. Jami | April 30, 2014 at 7:31 pm | Permalink

    Link exchange is nothing else but it is just placing the other person’s blog link on your page at
    appropriate place and other person will also do same in
    support of you.

  9. imvu credits | May 14, 2014 at 4:22 am | Permalink

    Heya! I’m at work surfing around your blog from my new iphone 3gs!

    Just wanted to say I love reading your blog and look forward to all your posts!
    Keep up the outstanding work!

  10. MichaelNego | May 19, 2014 at 8:03 pm | Permalink

    o5 safest site to buy Benadryl A number of online pharmacies like the France pharmacy are present on the net. It is bloody convenient in regard to people who real in remote area and find it obscure to pop in the http://trustfromcanada.com/catalog/Bestsellers/Benadryl-free-shipping.htm#v3w1 consumers are more charge awake then previously but do not want to compromise on rank generic cialis is the answer to all your pray. The cost of generic drugs is 40 to 67 % less than Canadian Pharmacy Benadryl mkkll36v

  11. StevenAgok | May 19, 2014 at 8:05 pm | Permalink

    p2 trustfromcanada.com Believe Clomid via Emedoutlet, before anything else health-related Concierge services. It provides the highest way to Accept Clomid online and diversified other medications from affordable prices. Clomid, or its generic counterpart Clomiphene Citrate, is an moving stimulant http://trustfromcanada.com/catalog/Bestsellers/Atarax-free-shipping.htm#ttso companies deal with in consultation with their researchers and consultants similarly the makers of Viagra also work in private coordination with their consultants who work on the Atarax from Canada 4ahp4fna

  12. Josephbula | May 19, 2014 at 8:32 pm | Permalink

    o9 can i buy Promethazine with paypal From this everything discourse, aren’t you getting a sense of nerve that people acquire on Viagra; those who are expanding their businesses not later than selling Viagra and also the impotency http://trustfromcanada.com/catalog/Bestsellers/Promethazine-free-shipping.htm#bo9q representing the treatment of men who savoir faire painfulness having and maintaining an erection. special offer buy Promethazine online c8asti7f

  13. WilliamHany | May 19, 2014 at 8:51 pm | Permalink

    hz where to buy Flovent in canada A right median is to bid that Clomid has a seventy percent celebrity rate. It is not a firm volley aspect, but a birch and miss sort of medication, so it’s a honourable sentiment that this medication is to some degree inexpensive. http://trustfromcanada.com/catalog/Bestsellers/Flovent-free-shipping.htm#tf6t Alike resemble to any pharmaceutical output, side effects may appear. The most continuing ones are:headaches, lodged with someone pains, muscle pains, oppressive nose or indigestions. These generally persist in the can you buy Flovent without prescripition z81qgxbc

  14. http://www.youtube. | September 5, 2014 at 4:05 pm | Permalink

    What’s up, every time i used to check webpage posts here in the early hours in the dawn, as i enjoy to
    learn more and more.

  15. Outboard motor | September 20, 2014 at 4:19 am | Permalink

    Helpful information. Lucky me I found your web site by accident, and I’m stunned why this accident didn’t came about earlier!
    I bookmarked it.

  16. cheat code for | December 24, 2014 at 3:18 am | Permalink

    Clash oof Clzns can be aan exceptionally well-known titpe among portable gamers
    throughout the world. The experience can be obtained upon iOS as well as Google android tools.
    The Supercell produced method, create your own community game is usually
    liberated to enjoy nevertheless to be able to expand, you should
    invest time of their time collecting resources along with products.
    The partticular exceedingly beautiful Clash off Clans hack will probably easily simplify items available ffor you and also
    permit you to enjoy tthe incentives of being prior to
    the competition. Wiith the reputable and also functioning bust,
    you can find limitless sources.
    Essentiwlly the most necessar versions forced to retain earning which include silver,
    gems, shield, elixir and others can be generated consistently so that you can go on profitable with
    out a lot problem. The actul a number off primary assets are platinum, elixir,
    black elixir along with jewels. All of these people
    pays to to create various areas of your current community andd mintain developing to
    achieve huge altitudes.
    The atual overcoke approach sport is often a much-loved among Google android in addition too iOS product entrepreneurs.
    The action works togvether with new iphone 4, apple ipad tablet, Android os cell phones inn addition to tablets.
    The colorful manifestation of your stunning community put together with some sort of variety associated with preventive as well as bothersome
    properties helps make the actual gameplay extremely enslaving.
    Youur oown job is usually tto dominate the particular dominion although dealing with
    weight through 1000s off people over the wordld and also imporove
    your. Clash of Clans functions diverse constructing houses broken down in to 3 important classes
    that is, armed service complexes, protecting buildings ass well as other houses.
    Thee army making classification functions barracks, black
    barracks, military get away, laboratory work along with
    tap ouut manufacturing area along with altar. Protective properties, for the reason that label implies consists off partitions,
    traps, air support, mortar, cannon, archer tower system and
    the like that’s vital to hold your villagers safe from assaults.
    Village hallway, fort as well as arrangements are usually
    some other complexes. Clash of Clans hack will prfovide you
    with having access to unlimited standard asserts that’s mandatory to build each one of these structures along with
    grow your current family.
    Television using a variety regarding fressh armies
    to create, guns to help invent and impressive properties to produce
    ones family strong, thhe actual method video game is actually a number of RPG along with podium support along with strategy elements.
    The inbitial blend causes it to be particularly fulfilling, especially
    for informkal ggame enthusiasts that are entering ike significawnt styles slowly but surely.
    The particular troiopers in the activity usually are divided in about three different sections dependant on their own durability
    although you will find specific heroes along with black elixir damaging troops.
    The spells made throughout spell manufacturing facility are usually part of
    the bad online game pattern, accustomedd to booth opponent troops as well aas kill
    these individuals. Each experienced game enthusiasts in addition too rookiews can conserve moment put in in amassinng assers
    utilizing the Clash of Clans hack tthat readily supplies an individual just about all that you might want.
    Players will probably gain the aggressive side with the
    totally free defraud limitations and will dominate other folks having profitable challenges.

    Be preparted tto experience a great immersive approach battle game.
    Pick upp your ownn no cost Clash of Clans defraud in this article inn the free giveaway site therefore you are usually off to enjoy the actual
    daring quest that this online game iss offering.

Post a Comment

Your email is never published nor shared. Required fields are marked *