Freelance Web Developer

Apr 13, 2010

Gtalk status checker with php

Today we are here to create a php script, that will show your gtalk status, ONLINE, OFFLINE, BUSY or AWAY. This code is based on the Google Talk chatback badge. We are fetching the url with help of cURL and then fetching status with Regular expressions.


As i told you we are using a google's Google Talk chatback badge with php. You must know your chatback url

Getting your chatback url

Its very simple, i am trying to describe in some steps-
Go to Google Talk chatback badge

Click on the "Edit" link and choose Url only (no frame) Style for your badge.

Now pic your chatback url


Here is the php code that will show your gtalk status -

// your url here 
$url "";
$ch curl_init($url);
$data curl_exec($ch); 
//parsing HTML 
preg_match('/<div class="r"><img id="b" src="(.*)" alt="" height="9" width="9"><img id="f"/i', 
$status substr($match[1],24,2);

if($status == 'on'){
    echo "AVAILABLE";
elseif($status == 'bu'){
    echo "BUSY";
    echo "OFFLINE";
    echo "AWAY";

Related articles

Weather forecast php application in 7 lines
Create your own gtalk robot
Php api for your gtalk

Labels: ,

By :