Add Google talk status on your website

Always wondered what could be the API which lets you interact with Google Talk ? Well I guess there isn’t one yetalk logo Show Google talk status on your websitet other than just creating bots. But what if you want to show the current Google Talk or GTalk status on your website or want it to use somewhere else like updating on twitter as well ?

Well in that case all you can do is just trick Google with its own tool. For this example we are going to use Google’s talkback badge. Please note that Google doesnt provide any authentic way or API to grab Gtalk’s status. This is a trick which grabs your latest status from the source of the Google badge( I know that sounds spooky ). We are going to use cURL, and other string function in PHP.

All you have to do is to repeat the following steps carefully !

Step 1 :

Grab the badge code by visiting the Google badge page. Make sure you check the “Show your status message” option, otherwise it will only show Available/Not Available.

Step 2 :

Now copy the embed code from the textarea and paste it in notepad. Analyze the embed code closely and copy the source of the iframe mentioned in the script tag. Look below to see example.
gtalk


Or if you can paste this code into Microsoft Word, then you have to copy the portion which gets underlined or link from the above code.

Step 3 :

Paste the URL in the following script (line #3), which you just copied in the Step 2.

';
	$Status .= '';
}else
{
	$Status = '';
}
print $Status;
/* grabs the data from the URL */

function get_data($url)
{
  $ch = curl_init();
  $timeout = 5;
  curl_setopt($ch,CURLOPT_URL,$url);
  curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
  $data = curl_exec($ch);
  curl_close($ch);
  return $data;
}
?>

This method is not always fool proof, but I have tested this script many times and with different status messages. There are many scripts available online which use the same badge code to get the status message. But most of them use fopen function of PHP which is not supported on most of the servers. However the above script uses cURL to get the data from the URL, so its more robust than other scripts.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

To submit your comment, click the image below where it asks you to...
Clickcha - The One-Click Captcha

WP-SpamFree by Pole Position Marketing

Please note: JavaScript is required to post comments.