The Twitter API

I’ve been messing with the Twitter API for the first time in the last few hours, and I’ve learned a TON.  I know – I’m jumping on the bandwagon late, but oh well.  I managed to create a script to retweet “stuff” based on the search functionality and I made a script to automatically follow people that post specific things.  I also managed to get my account suspended in like 2 hours due to suspicious activity – whoops.  I guess you live, you learn.  Basically everything for status updates and following uses CURL, which looks a little something like this:

<?php
 $username = "<username>";
 $password = "<password>"; t t
 $message = "<message content>";
 $url = '<API URL>';
 $curl_handle = curl_init();
 curl_setopt($curl_handle, CURLOPT_URL, "$url");
 curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
 curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($curl_handle, CURLOPT_POST, 1);
 curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "status=$message");
 curl_setopt($curl_handle, CURLOPT_USERPWD, "$username:$password");
 $buffer = curl_exec($curl_handle);
 curl_close($curl_handle);
?>

If you’re looking for more info on how to use twitter, check out this eSeries.  It’s a good resource.

So, have questions?  Let me know.  I’m hoping to do a twitter series soon!