开发者

How do I get my Gmail friends online status

开发者 https://www.devze.com 2023-02-01 07:52 出处:网络
I am developing one web application using (PHP JavaScript). I stuck to one point that I wanted to get my Gmail friend(s) online status.

I am developing one web application using (PHP JavaScript). I stuck to one point that I wanted to get my Gmail friend(s) online status.

e.g. I would provide one of my Gmail friend IDs i.e. abc@gmail.com as input to the API (if such an API is exist) and ultimately I wanted to track whether he is online or offline through normal script (PH开发者_如何学GoP/JavaScript/jQuery/other).

Please folks provide me your necessary pointer(s) in this case. Does such API/library exist in PHP, Java script, jQuery or any other? How do I achieve this?


This is xmpphp, may be can help http://code.google.com/p/xmpphp/

Use this module with some code like:

<?php
include("xmpp.php");
$conn = new XMPP('talk.google.com', 5222, 'user', 'password', 'xmpphp', 'gmail.com', $printlog=True, $loglevel=LOGGING_INFO);
$conn->connect();
while(!$conn->disconnected) {
    $payloads = $conn->processUntil(array('presence'));
    foreach($payloads as $event) {
        $pl = $event[1];
        print "Presence: {$pl['from']} [{$pl['show']}] {$pl['status']}\n";
    }
}
?>


You could use Google app engine's XMPP service(automagically scales) for this(It has a generous free quota). There is also a java SDK but coding in python would be way shorter. The api has a get_presence(jid, from_jid=None) function which

Returns True if the user is online and available, False if the user is not online or away.

You could just hook it up to http(webhook) to create a simple api. If you watch the video Developing and deploying an application on Google App Engine, you will learn how to develop a simple app and to deploy it to google app engine.

I think you can create this XMPP api in about 25 minutes(10 minutes to watch the video) and have learned a little bit about the fun to use language python.

0

精彩评论

暂无评论...
验证码 换一张
取 消