Twitter's API has Changed
Saturday, May 31, 2008

A couple days ago, I noticed that the Twitter statuses that show up on my website were no longer returning entries more than 24 hours old.  This was curious, because when I hit the URL directly, I was able to see all the updates.  Turns out the difference was authentication; if I logged out of Twitter, the direct URL gave me the same results that I saw on my website.  Yesterday, I noticed that no Twitter updates were appearing.  I figured Twitter was just having a bad day, but this morning I saw that it still wasn't working.  On investigation, it appears that Twitter has changed the behavior of their API.  Now, I can't get any status results at all without HTTP authentication.

Normally, this shouldn't present a problem.  But I was using the PHP function file_get_contents() to retrieve the data, and this doesn't support any HTTP request options.  The http_get() function does, but this requires a PECL extension, which isn't installed on my host's server, and which my host is not willing to install.

So began the quest for a workaround.  I noticed on the StartLogic control panel that there was a section listing PEAR modules.  I had thought this was empty, but then realized that it was actually just hidden; you needed to click on the heading to see the modules.  And so, scrolling through the list, I saw that among the modules listed was "HTTP_Request 1.2.4 stable".  Okay, interesting.  I pulled up the PEAR documentation, executed the example as written, and lo and behold, it worked!  This also provided a means for supplying basic HTTP authentication...which also worked just like the example.  Amazing.  So, I then updated my Twitter module, and we're back in business.

Leave a comment

Therefore God exalted Him to the highest place
and gave Him the name that is above every name,
that at the name of Jesus every knee should bow,
in heaven and on earth and under the earth,
and every tongue confess that Jesus Christ is Lord,
to the glory of God the Father.
— Philippians 2:9-11