OAuth in PHP (for Twitter)

October 16th, 2007

Mike released HTTP_Request_OAuth today, so I spent a little while this evening coding up Service_Twitter as helper class for making OAuth authorized requests against the Twitter API.

Both are early enough in the dev cycle to be called proof of concepts.

Mostly I wrote it because I had always envisioned there being wrapper libraries around the low level OAuth implementations that wrapped the calls, and constants, and as Mike graciously went out and wrote a low level library I felt compelled to write a wrapper.

Also twittclient, an interactive client for getting an authed access token, essential to bootstrapping development.

And nota bene, HRO currently only supports the MD5 signing algorithm, which is undefined in the core spec, and subject to change. (Just in case you didn’t believe me about the early state of things.)

update 2008/4/18

This code no longer works because Twitter has taken down their (slightly non-compliant) OAuth endpoint. When they add OAuth support back in, I’ll link to it.

5 Responses to “OAuth in PHP (for Twitter)”

  1. planets says:

    I want use your cool client. But I wonder what is “consumer key” and “secret passed” — both are arguments of your client. Please teach me. Thank you.

  2. jason says:

    hey, thanks for writing this stuff, there is definatly a lack of tutorials on how to use oauth with php. I’m trying to use this for a twitter site i’m developing. but i have a quick question, in mike’s code, he includes a file “HTTP/Request.php” but there’s no link to the actual file. Is this some “Standard” file that I’m just not aware of? If you could clear this up, that would be awesome. If you don’t know, I’ll ping Mike and see if he can help. Thanks in advance.

  3. Joe McCann says:

    You still supporting this? Twitter is now supporting oAuth in public beta.

  4. Kellan says:

    This post is from nearly 2 years ago, and documents working with an earlier version of the Twitter OAuth endpoint which they shut down nearly a year ago. Everything in this blog post is almost certainly wrong.

  5. Just went through the surprisingly unintuitive process of getting oAuth and twitter to play nice. Journey (and resulting code) up at http://blog.benjaminhill.info/archives/67