Codebird without cURL


Google Apps Engine doesn’t allow cURL, among lots of other things, like PHP native mail(), we will come back on this another day.

I needed to post a tweet from Google Apps Engine and couldn’t find a library using URL Fetch to do so, in few lines. It seems that everybody is using cURL!

So, I took an existing project: Codebird, a nice PHP class enabling to connect to Twitter API really easily, and added the methods to make file_get_contents() requests, with SSL, instead of using cURL.

Here it is:

Git repository: https://github.com/FabFab/codebird-php

Inspiration: http://foren.activevb.de/forum/webentwicklung/thread-265/beitrag-266/Twitter-OAuth-using-PHP-without/

Use:

\Codebird\Codebird::setConsumerKey(your_key, your_secret);
$cb = \Codebird\Codebird::getInstance();
$cb->setToken(your_token, your_token_secret);
$cb->setUseCurl(false);
$params = array(
 'status' => $message
);
$reply = $cb->statuses_update($params);
Fab
Latest posts by Fab (see all)

About Fab

Solutions Architect, I build great workflows for the news and media production industries. I play with data too.

Leave a comment

Your email address will not be published. Required fields are marked *