Sunday, May 22, 2011

oauth for php (and Ubuntu)

There is a "standard" PHP OAuth library, documented in the manual, and which is installed via pecl. There is no package shortcut under Ubuntu; you still have to use pecl
sudo pecl install oauth

If you get a complaint about no "phpize", install the "php5-dev" ubuntu package. And then if you get an error in "php_pcre.h" when compiling, then you need to install the "libpcre3-dev" ubuntu package.

Finally, you need to enable it. Still as root:
cd /etc/php5/conf.d
echo "extension=oauth.so" >oauth.ini

(This creates a config file just for oauth; you could also simply put the extension line in php.ini.)

Finally, "php -m" should list "OAuth", and you can create a OAuth object in your php scripts.

Ubuntu package manager lists "liboauth-php"; the minimal information, and the lack of mention of pecl, should have given me the clue that it is something different.

Also different is this: http://code.google.com/p/oauth-php/

5 comments:

  1. Awesome! Thanks for the quick howto!

    ReplyDelete
  2. Yeah, thank you very much, that was exactly what I needed!

    Hooray for you! :)

    ReplyDelete
  3. Cheers for this, I was stuck in classpath hell until I came across your post.

    ReplyDelete
  4. Saved and bookmarked!!

    Thanks a TON!!

    ReplyDelete
  5. Anybody discovered what this "liboauth-php" is?

    ReplyDelete