---
title: "Find Your Invisible Friends on Gmail"
description: "After google news in terminal i was much interested in playing with XMPP Extensible Messaging and Presence Protocol, my."
url: "https://h3manth.com/scribe/find-your-invisible-friends-gmail/"
canonical_url: "https://h3manth.com/scribe/find-your-invisible-friends-gmail/"
markdown_url: "https://h3manth.com/scribe/blog/find-your-invisible-friends-gmail.md"
publishDate: "2010-07-18T00:00:00.000Z"
author: "Hemanth HM"
category: "python"
tags: ["python","web"]
word_count: 293
reading_time_minutes: 2
x_markdown_tokens: 737
content_signal: "ai-train=yes, search=yes, ai-input=yes"
---

# Find Your Invisible Friends on Gmail

> After google news in terminal i was much interested in playing with XMPP Extensible Messaging and Presence Protocol, my.

After [google news in terminal](http://h3manth.com/content/google-news-terminal) i was much interested in playing with XMPP Extensible Messaging and Presence Protocol, my first mistake using it, gave me an idea of finding gmail friends who stay invisible, as i used to stay invisible most of the time, the idea made me learn many more steps and experiment more on it.

The below is the code that might help you to catch your hidden friends, but there is no program yet to make them reply!

The [xmpp-py-docs](http://xmpppy.sourceforge.net/apidocs/xmpp.client.Client-class.html) gives the clear picture of what is used in the code below. **xmpp.Client(jid.getDomain(), debug=[])** the debug parameter, helps to switch to the debug mode.

**Prerequisite:**
    
    
    sudo aptitude install python-xmpp python-dnspython
    

_The few extra details :_

> > > dir(node)
>>> 
>>> ['DBG', 'DEBUG', 'DisconnectHandler', 'Namespace', 'Port', 'RegisterDisconnectHandler', 'Server', 'UnregisterDisconnectHandler', '_DEBUG', '**doc** ', '**init** ', '**module** ', '_owner', '_registered_name', '_ route', 'auth', 'connect', 'connected', 'debug_flags', 'defaultNamespace', 'disconnect_handlers', 'disconnected', 'event', 'getRoster', 'isConnected', 'reconnectAndReauth', 'sendInitPresence', 'sendPresence']

## One success

> > > Node.connect((Gserver,5222)) tcpsock._sslObj = socket.ssl(tcpsock._ sock, None, None) 'tls'

**The code:**
    
    
    #!/usr/bin/env python
    # Find invisible gmail
    # Foundu.py
    # Author Hemanth.HM
    # Site : www.h3manth.com
    # Licensed under GNU GPL Version 3
    
    import xmpp
     
    # Edit the below as per your need
    ID = "user@gmail.com"
    PASS = "password"
    Gserver = "gmail.com"
    
    # Get the jabber id of the user from his email id 
    jabberId=xmpp.protocol.JID(ID)
    
    # Client instnace 
    Node=xmpp.Client(jabberId.getDomain(),debug=[])
     
    # Check connection
    if not Node.connect((Gserver,5222)):
        print "Could not connect to",Gserver
    
    # Authentication of the user
    if not Node.auth(jabberId.getNode(),PASS):
        print "Please check your password"
    
    # Send roster request and initial <presence/>. 
    Node.sendInitPresence(requestRoster=1)
    
    # Handler  
    def isVisible(con, event):
       if event.getType() == 'unavailable':
         print event.getFrom().getStripped()
    
    # Register the defined handler.
    # Register user callback as stanzas handler of declared type.
    Node.RegisterHandler('presence', isVisible)
    
    while Node.Process(1):
      pass
