PHP
PHP Validate Twitter Username Example
If you want to validate Twitter username using PHP i.e check whether its available for registration or not, this can be easily achieved using CURL. The following function will check whether twitter username exists for registration or if it is already registered.
How to Validate Twitter Username using PHP
Use the following code to validate Twitter Username using PHP:
<?php
function validate_twitter_username($username)
{
$twitter_url='http://api.twitter.com/1/users/show/'.$username.'.xml';
$init = curl_init();
curl_setopt ($init, CURLOPT_URL, $twitter_url);
curl_setopt ($init, CURLOPT_CONNECTTIMEOUT, 20);
curl_setopt($init, CURLOPT_NOBODY, 1);
curl_setopt($init, CURLOPT_HEADER, 1);
curl_setopt($init, CURLOPT_RETURNTRANSFER, true);
curl_exec($init);
$result_header = curl_getinfo($init, CURLINFO_HTTP_CODE);
curl_close($init);
// IF username does note exist, then it means its avilable for registration
if( '404' == $result_header )
{
return 'Username is available.';
}
else
{
// This means username is already taken
return 'Username already taken.';
}
}
//Enter the username you want to check below and that's it.
$username = 'extreme';
echo validate_twitter_username($username);
?>That’s it!
Do you know a simpler way to validate twitter username? If yes, please share it with us in your comments below.
you might have an amazing blog here! would you wish to make some invite posts on my weblog?
bizzibiz
February 6, 2012 at 1:14 am
Thanks for the comment. Are you looking for posts in specific area? If yes, please indicate.
Robert
February 6, 2012 at 10:02 am
That is the suitable blog for anyone who needs to seek out out about this topic. You understand a lot its virtually arduous to argue with you (not that I actually would want…HaHa). You definitely put a new spin on a subject thats been written about for years. Nice stuff, simply nice!
February 7, 2012 at 5:25 pm
Thanks for the comment. Will try to simply things even more in the future.
Robert
February 10, 2012 at 8:04 am
When I initially commented I clicked the -Notify me when new comments are added- checkbox and now each time a comment is added I get four emails with the identical comment. Is there any means you may take away me from that service? Thanks!
Ray Knapke
February 8, 2012 at 10:00 am
You have either already unsubscribed or not subscribed at all. If you still continue to experience such an error, please send the screenshot of the subscription message that you received and I will do the needful.
Robert
February 10, 2012 at 8:05 am
Spot on with this write-up, I really assume this web site needs rather more consideration. I’ll in all probability be once more to read much more, thanks for that info.
Nettie Geren
February 10, 2012 at 6:46 pm
Awesome website! How did you get this design?
Darmowe konto dla dzieci
March 14, 2012 at 2:30 am
This is a custom theme that we created.
Robert
March 17, 2012 at 6:42 am
I genuinely love the theme on your site, I run a internet web site, and i would adore to use this theme. Is it a free of charge style, or is it custom?
demograss plus
March 15, 2012 at 1:19 pm
Hi,
This is a totally custom theme that we have built from scratch. If you want to get custom theme created for your own WordPress blog, simply contact us and we will help you out.
Robert
March 17, 2012 at 6:40 am
There are some fascinating time limits on this article however I don’t know if I see all of them middle to heart. There’s some validity but I will take hold opinion until I look into it further. Good article , thanks and we wish extra! Added to FeedBurner as nicely
March 28, 2012 at 3:29 pm
I’m very pleased with the articles on your blog. I recieve numerous tips which helped me to.
Carl
May 26, 2012 at 5:42 pm