Home     Wordpress     Codex

Archive for the ‘Twitter’ Category

HOWTO: Creating the Simplest Twitter API Client in PHP

May 21st, 2009 by admin | No Comments | Filed in Twitter

Do you run a website? Heard about the Twitter API? Try it!

I have been playing around with the Twitter API lately, all though the OpenAuth is a bit more hassle they still support the ‘old’ API for a bit longer. Twitter has not set a definitive date on when these applications will stop working but it will happen.
In the mean time, it’s a good way to learn how to play with the API without dealing with all the openauth stuff.

I have created an example function that you can use to create your own Twitter applications, it does not support or have any sense of sessions but if you intend to play, check it out! Extend it, tell me about your changes!

You need Zend for this example to work, and more specifically the Zend Json decoder part. It helps parsing the JSON information sent from Twitter.

<?php
/* Simple Twitter API Client Example utilizing Zend/Json
* http://www.cfg.no/ – Espen Holm Nilsen 20090521
*/
require_once ‘Zend/Json.php’;

function twitterJsonGet ($strUser, $strPassword, $strUrl) {
$strBasicAuth = base64_encode($strUser . ‘:’ . $strPassword);
$strRequest = “GET ” . $strUrl . “.json HTTP/1.1\nAuthorization: Basic ” . $strBasicAuth . “\nUser-Agent: PHPTwitter 1.0 (http://www.cfg.no)\nHost: twitter.com\nAccept: */*\r\n\r\n”;
$fd = fsockopen(‘twitter.com’, 80);
if (!$fd)
die(“Could not connect to Twitter”);
fputs($fd, $strRequest);
while (!feof($fd)) $buf .= fgets($fd, 1024);

$res = explode(“\r\n\r\n”, $buf);

if (!preg_match(“/^HTTP\/1\.1\s200\sOK/”, $res[0]))
return FALSE;

return Zend_Json::Decode($res[1]);
}

if ($_POST['twitteruser'] && $_POST['twitterpass']) {
$user = twitterJsonGet($_POST['twitteruser'], $_POST['twitterpass'], ‘/account/verify_credentials’);
print “You are <a href=’http://twitter.com/” . $user['screen_name'] . “‘>” . $user['screen_name'] . “</a><br>”;
print “You follow ” . $user['friends_count'] . ‘ people and have ‘ . $user['followers_count'] . ” followers.<br>”;
}

?>

<form action=’?’ method=’POST’>
Twitter username<br><input type=”text” name=”twitteruser”><br>
<br>
Twitter password<br><input type=”password” name=”twitterpass”><br>
<input type=”submit” value=”Who am I?”>
</form>

The application example runs live here: http://arpa.no/twitter.php
Since it’s Twitter specific, you should Tweet it, or retweet if you saw it in a Tweet! :D

Good luck, let me know how you do!

Tags: , ,

14 Excellent Power Twitter Tools and Tips

May 21st, 2009 by admin | 2 Comments | Filed in Twitter

Are you a Twitter user? Looking to Twitter more effectively?
Recently created a new Twitter account because of big differences in my crowd, my cisco network twitter user
These are 14 applications that will give you more control over Twitter!

  1. TweetDeck is an excellent application for Twitter. You can group the people you are following, have widgets with custom searches. This application makes it possible to stay on top at all times! This application is also one of the most popular Twitter clients.

    Pros: Time saving and clean overview!

  2. Twitterrific is a Twitter App for iPhone, makes it possible to Tweet on the move. This is the way Twitter was intended to be used.
    twitterific

    Pros: Mobility!

  3. Twibble Mobile is an application for other java enabled smart phones, like the Nokia N95 or BlackBerry.
    Twibble Mobile

    Twibble Mobile

    Pros: Mobility, tweet on the go!

  4. TwitIQ is a genious application that looks very much like the usual Twitter web interface, but it is massively extended. It also supports managing of multiple accounts, so for you (I read somewhere) 16% of users this can be a good choice for a primary Twitter web interface.
    twitiq_logo

    Pros: Management of multiple accounts, time saving.

  5. SocialWhois is a powerful application, their catch line is “who you should follow, and why.”. This is a great way to extend your Twitter bubble and find new people to socialize with. You can search for people based on their interests, hence find people who are relevant and not always just go for the most followed ones.
    socialwhois

    Pros: Extend your Twitter network without just following all the popular people

  6. Your Twitter Karma is an application where you can find the self-centered people who you are following but are not following you back, you can check the ones you want to unfollow and just press one button to bulk unfollow the people you want.

    Pros: Effectively manage your Twitter Network, and do cleanups with bulk operations.

  7. TwitScoop
    twitscoop_logo
    TwitScoop keeps a track of what’s buzzing on Twitter and it displays it very playfully and graphic, the tag cloud is dynamically updated. You can search for words and get a graph of their popularity. This is just an awesome application!

    Pros: Keep a track of what’s buzzing!

  8. TIP: Maintain Your Twitter Profile
    You should choose your Twitter username wisely, it’s preferably going to have a connection with you or your company. Twitter usernames like ’supahdupahwoman90′ gives an extra unprofessional touch, and may cost you a bunch of followers, ONLY because of the user name.

    Keep your Twitter profile updated, unless you have one, get a profile picture and maybe also personalize your profile with a custom background image, but don’t get too noisy with the colors.

  9. TwitPic
    TwitPic helps you post pictures to Twitter, this is the most popular way to share images on Twitter today. A lot of Twitter clients have built-in support for TwitPic. It is worthy a spot here!
    twitpic-logo

    Pros: Share pictures on Twitter.

  10. Twubble helps you extend your Twitter network, it goes through your friends and finds people that two or more friends are following, a lot like Facebooks friend suggestion way of finding people.
    twubblelogo

    Pros: Find new people fast.

  11. Seesmic Desktop has gained a lot of popularity lately, it is a good alternative to TweetDeck and users seem to be arguing about which one is the best one.
    seesmic_desktop_logo

    Pros: Time saving and clean overview, like TweetDeck.

  12. Digsby is a popular IM application; it supports Twitter, Facebook, MSN, email and a lot more. It is an all-in-one IM client.
    digsby_logo

    Pros: Support for multiple networks, time saving.

  13. TIP: Join discussion
    When I first joined Twitter I was like everyone else just tweeting things like “I’m on the subway”, and in my primary language. Be interesting, and most of all; join discussion! Think about your social life, do you join discussions or do you just run into a bunch of people who are talking, and start talking about that you took the subway there and the colors of the seats?
    My guess is no, and you should follow the same etiquettes on Twitter.
  14. Twitt(url)y is great for catching what links are the most popular on Twitter, in real time!
    twitturly_logo

    Pros: Keep track of what’s popular!

Which Twitter applications do you use? Post a comment!

Did you like this post? follow me on Twitter!

Tags: , , , , , , , , ,