jtGraphic

Personal blog of James Thompson: Ramblings of an Internet addict...

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!

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • StumbleUpon
  • Technorati
  • MySpace
  • Twitter
  • Sphinn
  • Reddit

2 ResponsesLeave one →

  1. JAMEE

     /  February 17, 2010

    I have been searching for a long time for this! Thank God I found your site on Bing.

    Thx

    me

    Reply

  2. Rachal Linman

     /  February 17, 2010

    Hi cheers for an incisive post, I really found your blog by mistake while looking on Goole for something else closely related, in any event before i ramble on too much i would just like to say how much I enjoyed your post, I have bookmarked your site and also taken your RSS feed, Once Again thanks for the blog post keep up the great work.

    Reply

Leave a Reply