Posted on June 14, 2009 by Atif
Filed Under PHP, Twitter
Got over 1000 followers on twitter? And you want to flaunt your twitter follower count proudly on your blog. The following PHP code is a PHP cURL code implementation to pull out the twitter followers using REST API. It will get you the number of followers on twitter using the cURL library. Just change the $screen_name and the script is pretty self explanatory. The code is tested working, You are free to do anything with this code, I take no responsibility further however you can ask me for support. I will try to help you out if I can.
NOTE: The code won't work for an hour if you 100 API calls per hours are completed.
<?
// get the number of followers
$screen_name = "atif089";Â Â Â Â Â Â // dont forget to chagne your username
$html = process("http://twitter.com/users/show.xml?screen_name=$screen_name");
// Parse the number of followers
$pattern = '<followers_count>(.*)<\/followers_count>';
ereg($pattern, $html, $matches);
// change this HTML as per your requirement
echo "<a href=\"http://twitter.com/$screen_name\">Follow me on twitter: (".$matches[1]." followers)</a>";
/**
* process : This method open a URL via cURL library
*
* @param string $url (must) This is the URL that you would like to open
* @param string $postargs (optional) Any arguments that you would like to send via POST method
*
*/
function process($url,$postargs=false){
$ch = curl_init($url);
if($postargs !== false){
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postargs);
}
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
?>
Posted on May 31, 2009 by Atif
Filed Under Twitter

Twitter is a great place to make friends. But I must say that there may be many things that may irk your follower or friends. So this week I went more around twitter creating some friends and asking them what they hate. Also on the list I added things that I hate.
Auto Direct Messages
Ah! This is the most annoying thing. I just hate Auto Direct Messages. These are the messages sent automatically when you follow someone. I have asked a couple of friends of mine, regarding the most annoying thing on twitter and most of them said the same thing. Auto DMs. So this goes on top of the list.
cheth @atif089 Auto-Dm’s and a non-stop stream of Friendfeed/Twitter feed is annoying. #twitter #tweet #tweeple
syedbalkhi @atif089 Auto-DM reply piss me off alot, but tons of twitterfeed sent out all at once is really annoying as well.
mistygirlph@atif089 I guess it would be auto DMing asking if i want a million followers. I would appreciate it more just saying hello
Advertisements
This is most frustrating thing on twitter. I have seen a lot of people use some sort of PPC advertising on twitter like be-a-magpie and twtad. Apart from that most people put up affiliate links to clickbank products which is even more frustrating. Well for myself, I simply unfollow anyone in my friendlist whollows the above practises.
arnteriksen @atif089 Hehe – I guess it would be the ones that talk about gaining 30000 of followers in a few weeks.LOL #follow #twitter #tweet #tweeple
jayaugust@atif089 affiliate links, ‘marketing guru’s’ in general, spammers… All annoy the crap outta me.
Asking for ReTweets
Personally asking for ReTweeets may be a bit hindering for some people. Even I ask some people for ReTweets. But I advice you before asking a ReTweet make sure your content is good enough and make friends first. Simply adding people and asking for RTs wont work.
Direct Messages (DM)
This is more of my personal reason than a collective reason. I don’t link direct messages unless it is very personal. Rather I want people to send me an @reply which I usually keep checking.
naldzgraphics @atif089 those tweeple who DM me 3-4 times with the same tweets .
Self Promotion
Previously I only used to self promote my self on all social media websites like SU, Digg and Twitter. Trust me self promotion on social media is a big FAIL. The best practice would be make friends and submit each others content and help each others. This way you would get some good name and trust as well as traffic which is the key. This also includes boasting.
schallner @atif089 Brag about how many people they are unfollowing (every hour), and how many new followers they have to sort through.
0 Updates
Lol I have seen many account like this. These accounts tend to have a couple of thousands of followers but no updates. I don’t know why people follow them on twitter. Stay away from those people because I probably think they are out for some serious SPAM!
Spam
Even though twitter is very efficient enough in controlling SPAM but sometimes I get to see some people spamming the system like the most popular follow and unfollow.
Sumeet @atif089 Following and unfollowing after I follow back really gets on my nerves..
Asking for someone to click your ads
Well I won’t like to point out but I have seen some people asking you on twitter to click their Google Ads. personally it didn’t happened to me yet.
Bots / Feeds / FollowFridays etc.
People don’t like to see only feeds coming through your twitter account. Its a social media website and not a mashup site. Imporper #followfridays and protecting your updates.
DinOthman @atif089 too much twitterFeeds, nothing but quotes, #followfriday RTs and auto-DMs piss me off…
Nicksc @atif089 Excessive twitterfeed tweets annoy me the most. In fact, if I see more than two on the same page, I unfollow!
thomasmmm @atif089 impolite twitter snobbing
bexdeep @atif089 When u reciprocate to those who follow u, u find that ur request is pending. Thats quite irritating!. #twitter #tweet #tweeple
Update: Oh I mistook DinOthman’s tweet actually. He means he doesnt like followfrisday RTs i.e people simple RT each other’s followfridays, how funny is that.
Posted on May 06, 2009 by Atif
Filed Under Twitter
The idea behind this is simple. Everyone know how quick twitter is reaching the top of social media web. Twitter is a great source of traffic particularly if you have a good number of followers. Tweetmeme is a digg like website where user can submit stories through twitter. If you need some quick hits from twitter, I recommend you to add a tweetmeme button on each of your blog posts like I did here. (If you like this post, please don’t forget to retweet it)
Add this code at the end of the functions.php file in your theme to embed a retweet button. If you want to know how to automatically tweet your blog posts read our post on How to automatically tweet your blog post
function tweetmeme($content) {
$code = '<div class="alignleft">
<script src="http://tweetmeme.com/i/scripts/button.js" type="text/javascript"></script></div>
';
if (is_single()) {
return $code.$content;
} else {
return $content;
}
}
add_filter('the_content','tweetmeme');
Posted on April 20, 2009 by Atif
Filed Under PHP, Twitter
Hey guys, this code will let you automatically tweet your latest blog post to twitter. Lol didn’t understand? What I mean to say is each time you write a new post, the following PHP code will automatically update your twitter timeline with that post. Cool! keep reading..
Open up the functions.php file in your current theme and simple add the following code. Dont forget to change the username and password in the code. Save the file. Thats it, you’re done.
Plugin coming tomorrow for those who are scared to mess up with the theme, since its already 12AM here and I want to sleep. Oh yes, here is the code lol
for those who are
function twitterit($post_id) {
$username = "atif089";Â Â Â Â Â // write your twitter username
$password = "abcdefg";Â Â Â Â Â // write your twitter password here
$post = get_post($post_id);
$title = get_the_title($post->ID);
$post_permalink = get_permalink($post->ID);
$ch = curl_init();Â Â Â Â Â // initialize cURL
// lets make a tinyurl of your post
curl_setopt($ch, CURLOPT_URL, "http://tinyurl.com/api-create.php?url=$post_permalink");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$tinyurl = curl_exec($ch);Â // get tinyurl of permalink
// now publish it to twitter
curl_setopt($ch, CURLOPT_URL, "http://twitter.com/statuses/update.xml");
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_POSTFIELDS, "status=$title $tinyurl");
$buf = curl_exec($ch);
//echo $buf;
curl_close($ch);
}
add_action('publish_post','twitterit',10,2);