PunJab - A Jabber HTTP client interface.
PunJab is a HTTP, jabber client interface. It is a SOAP, XMLRPC, JEP-0025, or JEP-0124 server that allows persistent client connections to a jabber server. It can be used for many things, but its main purpose is to allow for stateless applications (ie web) a stateful connection to jabber.
News
Downloads
CVS
Docs
Bugs
JWChat HOWTO
Demo
XMLRPC API
About PunJab
XMLRPC Demo
SourceForge.net Logo

Punjab XMLRPC API


This the XML-RPC api to Punjab. XML-RPC allows programs to make procedure calls over the internet, regardless of differing operating systems and environments. Punjab provides a set of these procedure calls to make client connections to a jabber server.

Test XMLRPC Server at thetofu.com :
'proxy' => "http://thetofu.com:32080/?session=xmlrpc_client"
Table of contents
connect - connect and login to a jabber server.
disconnect - disconnect from the jabber server and close your session.
start_contact - subscribe to a jid's presence.
start_roster - request your jabber roster.
get_roster - get your roster that is stored in punjab.
send_presence - Send a presence packet to a jabber entity.
get_presence - get a presence packet that has been sent to you.
send_message - send a message packet to a jabber entity.
get_message - get a message that has been sent to you and delete it from punjab.
check_message - get a message that has been sent to you and do not delete it from punjab.
get_iq - get iq packets that have been sent to you.
send_xml - send any xml to the jabber server.

connect -


connect and login to a jabber server.

Mode Description

Given all of the required information on a post, it will connect you to the given jabber server and return a session id.

Arguments

  1. [string] (required)
    • jid - jabber id (format : username@jabberserver.tld/Resource
  2. [string] (required)
    • pass - your jabber password (for jabberserver.tld)
  3. [string] (defaults to 5222)
    • port - the jabber server port
Example Connect :
POST http://thetofu.com:32080/?session=jabber_client
Accept: text/xml
Accept: multipart/*
Content-Length: 230
Content-Type: text/xml

<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
   <methodName>connect</methodName>
       <params>
          <param>
             <value>
                 <string>tofu@thetofu.com/Resource</string>
             </value>
          </param>
          <param>
             <value>
                 <string>SecretPassword</string>
             </value>
          </param>
       </params>
</methodCall>

Return Values

  1. [string]
    • sid - punjab session id
Example Return Connect :
HTTP/1.0 200 (OK) (OK) 
Content-Length: 182
Content-Type: text/xml

<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
     <params>
         <param>
             <value>
                <string>1841aee81fa87e9218dd21c0e590860f9651781f@punjab</string>
             </value>
         </param>
     </params>
 </methodResponse>

disconnect -


disconnect from the jabber server and close your session.

Mode Description

Given all of the required information on a post, it will disconnect you from the punjab session and the jabber server associated with that session and return 1.

Arguments

  1. [string] (required)
    • sid - punjab session id
Example disconnect :
POST http://thetofu.com:32080/?session=jabber_client
Accept: text/xml
Accept: multipart/*
Content-Length: 209
Content-Type: text/xml

<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
       <methodName>disconnect</methodName> 
       <params>
             <param>
                <value>
                   <string>1841aee81fa87e9218dd21c0e590860f9651781f@punjab</string>
                </value>
             </param>
       </params>
</methodCall>

Return Values

  1. [int]
    • 1
Example Return disconnect :
HTTP/1.0 200 (OK) (OK) 
Content-Length: 130
Content-Type: text/xml

<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
     <params>
         <param>
             <value>
                <int>1</int>
             </value>
         </param>
     </params>
</methodResponse>

start_contact -


Subscribe to a jabber entities presence.

Mode Description

Given all of the required information on a post, it will send a subscribe request to the jid and also add the jid to your roster.

Arguments

  1. [string] (required)
    • sid - punjab session id
  2. [string] (required)
    • service - The type of Service we are sending too. Example: Jabber
  3. [string] (required)
    • to - the jabber id (username@jabberserver.tld)
  4. [string]
    • nick - the jabber entity's nick name or alias
  5. [string]
    • group - the roster group you would like this entity filed under.
  6. [int] (required 1 or 0)
    • request - Send presence to subscribe to the jid
Example start_contact :
POST http://thetofu.com:32080/?session=xmlrpc_client
Accept: text/xml
Accept: multipart/*
Content-Length: 494
Content-Type: text/xml
 
<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
   <methodName>start_contact</methodName>
   <params>
     <param>
       <value>
         <string>4551e9b6c6095ba42c83eb21c3daa@punjab</string>
       </value>
     </param>
     <param>
        <value>
          <string>Jabber</string>
        </value>
     </param>
     <param>
        <value>
           <string>zorncj@jabber.musc.edu</string>
        </value>
     </param>
     <param>
       <value>
           <string>Test Nick</string>
       </value>
     </param>
     <param>
       <value>
         <string>TestGroup</string>
       </value>
     </param>
     <param>
         <value>
            <int>1</int>
         </value>
     </param>
   </params>
</methodCall>

Return Values

  1. [int]
    • 1
Example Return start_contact :
HTTP/1.0 200 (OK) (OK)
Content-Length: 130
Content-Type: text/xml
 
<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
   <params>
     <param>
        <value>
           <int>1</int>
        </value>
     </param>
   </params>
</methodResponse>

start_roster -


Request your jabber roster.

Mode Description

Given all of the required information on a post, it will send a request to the jabber server for your roster.

Arguments

  1. [string] (required)
    • sid - punjab session id
Example start_roster :
POST http://thetofu.com:32080/?session=xmlrpc_client
Accept: text/xml
Accept: multipart/*
Content-Length: 211
Content-Type: text/xml
 
<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
   <methodName>start_roster</methodName>
   <params>
       <param>
           <value>
               <string>a7ec309d8904551e9b6c6095ba42c83eb21c3daa@punjab</string>
           </value>
       </param>
   </params>
</methodCall>

Return Values

  1. [array] - an array of structs is returned
    • [struct]

    • Containing Keys :
      • jid - (scalar) jabber id
      • name - (scalar) nick name
      • groups - (struct) a struct containing your group categories in which this jid resides.
        • groupN - (scalar) group category name (N is a number 1,2,3...)
      • id - (int)
      • ask - (scalar)
      • subscription - (scalar) the subscription type of the jid
Example start_roster return :
HTTP/1.0 200 (OK) (OK)
Content-Length: 5493
Content-Type: text/xml

<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
  <params>
    <param>
      <value>
        <array>
          <data>
            <value>
              <struct>
                <member>
                  <name>jid</name>
                  <value>
                    <string>zorncj@jabber.itlab.musc.edu</string>
                  </value>
                </member>
                <member>
                  <name>groups</name>
                  <value>
                    <struct/>
                  </value>
                </member>
                <member>
                  <name>name</name>
                  <value>
                    <string>Test Nick</string>
                  </value>
                </member>
                <member>
                  <name>id</name>
                  <value>
                    <int>11</int>
                  </value>
                </member>
                <member>
                  <name>subscription</name>
                  <value>
                    <string>to</string>
                  </value>
                </member>
                <member>
                  <name>ask</name>
                  <value/>
                </member>
              </struct>
            </value>
          </data>
        </array>
      </value>
    </param>
  </params>
</methodResponse>

get_roster -


Request your jabber roster.

Mode Description

Given all of the required information on a post, it will send a request to the jabber server for your roster.

Arguments

  1. [string] (required)
    • sid - punjab session id
Example get_roster :
POST http://thetofu.com:32080/?session=xmlrpc_client
Accept: text/xml
Accept: multipart/*
Content-Length: 211
Content-Type: text/xml
 
<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
   <methodName>get_roster</methodName>
   <params>
       <param>
           <value>
               <string>a7ec309d8904551e9b6c6095ba42c83eb21c3daa@punjab</string>
           </value>
       </param>
   </params>
</methodCall>

Return Values

  1. [array] - an array of structs is returned
    • [struct]

    • Containing Keys :
      • jid - (scalar) jabber id
      • name - (scalar) nick name
      • groups - (struct) a struct containing your group categories in which this jid resides.
        • groupN - (scalar) group category name (N is a number 1,2,3...)
      • id - (int)
      • ask - (scalar)
      • subscription - (scalar) the subscription type of the jid
Example get_roster return :
HTTP/1.0 200 (OK) (OK)
Content-Length: 5493
Content-Type: text/xml

<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
  <params>
    <param>
      <value>
        <array>
          <data>
            <value>
              <struct>
                <member>
                  <name>jid</name>
                  <value>
                    <string>zorncj@jabber.itlab.musc.edu</string>
                  </value>
                </member>
                <member>
                  <name>groups</name>
                  <value>
                    <struct/>
                  </value>
                </member>
                <member>
                  <name>name</name>
                  <value>
                    <string>Test Nick</string>
                  </value>
                </member>
                <member>
                  <name>id</name>
                  <value>
                    <int>11</int>
                  </value>
                </member>
                <member>
                  <name>subscription</name>
                  <value>
                    <string>to</string>
                  </value>
                </member>
                <member>
                  <name>ask</name>
                  <value/>
                </member>
              </struct>
            </value>
          </data>
        </array>
      </value>
    </param>
  </params>
</methodResponse>

send_presence -


Send a presence packet to a jabber entity.

Mode Description

Given all of the required information on a post, it will send a jabber presence message to the server or what you set the 'to' parameter to be.

Arguments

  1. [string] (required)
    • sid - punjab session id
  2. [string]
    • to - the jabber id you are sending presence to.
  3. [string]
    • type - the type of presence packet you are sending
  4. [string]
    • show - the message you want to show
  5. [string]
    • status - the status you want to show
Example send_presence :
POST http://thetofu.com:32080/?session=xmlrpc_client
Accept: text/xml
Accept: multipart/*
Content-Length: 212
Content-Type: text/xml
 
<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
  <methodName>send_presence</methodName>
  <params>
    <param>
      <value>
        <string>a7ec309d8905ba42c83eb21c3daa@punjab</string>
      </value>
    </param>
  </params>
</methodCall>

Return Values

  1. [int]
    • 1
Example Return send_presence :
HTTP/1.0 200 (OK) (OK)
Content-Length: 130
Content-Type: text/xml
 
<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
  <params>
    <param>
      <value>
        <int>1</int>
       </value>
     </param>
  </params>
</methodResponse>

get_presence -


Get a presence packet that has been sent to you.

Mode Description

Given all of the required information on a post, it will send a request to the jabber server for any presence packets sent to you.

Arguments

  1. [string] (required)
    • sid - punjab session id
  2. [string]
    • to - the jabber id for the receiver of the presence packet
  3. [string]
    • from - the jabber id for the sender of the presence packet
Example get_presence :
POST http://thetofu.com:32080/?session=xmlrpc_client
Accept: text/xml
Accept: multipart/*
Content-Length: 211
Content-Type: text/xml
 
<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
  <methodName>get_presence</methodName>
  <params>
    <param>
      <value>
        <string>324252423a742c83eb21c3daa@punjab</string>
      </value>
    </param>
  </params>
</methodCall>

Return Values

  1. [array] - an array of structs is returned
    • [struct]

    • Containing Keys :
      • priority - (scalar) the priority of this presence packet
      • time_stamp - (int) the time stamp for this presence packet
      • show - (scalar) the show element of the presence packet
      • status - (scalar) the status element of the presence packet
      • to_attr - (scalar) the to attribute of the presence packet
      • from_attr - (scalar) the from attribute of the presence packet
      • id - (int) the id attribute of the presence packet
      • type - (scalar) the type attr of the presence packet
      • xml - (scalar) the entire presence xml packet
Example Return Connect :
HTTP/1.0 200 (OK) (OK)
Content-Length: 6150
Content-Type: text/xml
 
<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
  <params>
    <param>
      <value>
         <array>
           <data>
             <value>
                <struct>
                   <member>
                     <name>time_stamp</name>
                     <value>
                        <int>20040415195211</int>
                     </value>
                   </member>
                   <member>
                     <name>priority</name>
                     <value/>
                  </member>
                  <member>
                    <name>show</name>
                    <value/>
                  </member>
                  <member>
                     <name>status</name>
                     <value/>
                  </member>
                  <member>
                     <name>to_attr</name>
                     <value>
                         <string>tofu@thetofu.com</string>
                     </value>
                  </member>
                  <member>
                    <name>xml</name>
                    <value>
                          <string>
                          &lt;presence to='tofu@thetofu.com' from='thepug@thetofu.com/Home'>
                              &lt;x xmlns='jabber:x:delay' stamp='20040413T02:25:39' from='thepug@thetofu.com/Home'/>
                              &lt;x xmlns='jabber:x:delay' stamp='20040413T02:25:39' from='thepug@thetofu.com/Home'/>
                              &lt;x xmlns='jabber:x:delay' stamp='20040413T16:49:46' from='thepug@thetofu.com/Home'/>
                              &lt;x xmlns='jabber:x:delay' stamp='20040414T17:01:28' from='thepug@thetofu.com/Home'/>
                              &lt;x xmlns='jabber:x:delay' stamp='20040414T20:22:42' from='thepug@thetofu.com/Home'/>
                              &lt;x xmlns='jabber:x:delay' stamp='20040414T21:12:53' from='thepug@thetofu.com/Home'/>
                          &lt;/presence>
                      </string>
                   </value>
                  </member>
                  <member>
                  <name>from_attr</name>
                  <value>
                     <string>thepug@thetofu.com/Home</string>
                  </value>
                  </member>
                  <member>
                      <name>presence_id</name>
                       <value><int>1</int></value> 
                  </member>
                  <member>
                    <name>type</name>
                    <value/>
                  </member>
                  <member>
		     <name>id</name>
                     <value/>
                   </member>
                </struct>
            </value>
         </data> 
       </array>
     </value>
   </param>
  </params>
</methodResponse>

send_message -


Send a message packet to a jabber entity.

Mode Description

Given all of the required information on a post, it will send a jabber message to a jabber id.

Arguments

  1. [string] (required)
    • sid - punjab session id
  2. [string]
    • to - the jabber id of the sender of the message packet
  3. [string]
    • subject - the subject of the message packet
  4. [string]
    • body - the body of the message packet
  5. [string]
    • type - the type attribute of the message packet (error,message,chat,)
  6. [string]
    • id - the id attribute or thread id of the message packet
Example send_message :
POST http://thetofu.com:32080/?session=xmlrpc_client
Accept: text/xml
Accept: multipart/*
Content-Length: 457
Content-Type: text/xml
 
<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
  <methodName>send_message</methodName>
  <params>
    <param>
      <value>
        <string>a7ec309d8904551e9b6c6fdsfdfdfdf43432341c3daa@punjab</string>
      </value>
    </param>
    <param>
      <value>
        <string>zorncj@jabber.musc.edu</string>
      </value>
    </param>
    <param>
      <value/>
    </param>
    <param>
      <value>
        <string>yoyoyo</string>
      </value>
    </param>
    <param>
      <value>
        <string>chat</string>
      </value>
    </param>
    <param>
      <value><int>342432432</int></value>
    </param>
  </params>
</methodCall>

Return Values

  1. [int]
    • 1
Example Return send_message :
HTTP/1.0 200 (OK) (OK)
Content-Length: 130
Content-Type: text/xml
 
<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
  <params>
    <param>
      <value>
         <int>1</int>
      </value>
    </param>
  </params>
</methodResponse>

get_message -


get a message that has been sent to you and deletes it from punjab.

Mode Description

Given all of the required information on a post, it will send a request to the jabber server for any message packets sent to you.

Arguments

  1. [string] (required)
    • sid - punjab session id
  2. [string]
    • to - the to attribute of the message packet you would like to retrieve
  3. [string]
    • type - the type attribute of the message packet you would like to retrieve (error,message,chat,)
  4. [string]
    • id - the id attribute or thread id of the message packet you would like to retrieve
  5. [string]
    • from - the from attribute of the message you would like to retrieve
Example get_message :
POST http://thetofu.com:32080/?session=xmlrpc_client
Accept: text/xml
Accept: multipart/*
Content-Length: 210
Content-Type: text/xml
 
<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
  <methodName>get_message</methodName>
  <params>
    <param>
      <value>
        <string>a7efdsfdfddsf435235c30fdffds95ba42c83eb21c3daa@punjab</string>
      </value>
    </param>
  </params>
</methodCall>

Return Values

  1. [array] - an array of structs is returned
    • [struct]

    • Containing Keys :
      • time_stamp - (int) the time stamp for this message packet
      • status - (scalar) the status element of the message packet
      • to_attr - (scalar) the to attribute of the message packet
      • from_attr - (scalar) the from attribute of the message packet
      • id - (int) the id attribute of the message packet
      • type - (scalar) the type attr of the message packet
      • xml - (scalar) the entire message xml packet
      • thread - (scalar) the thread element of the message packet
      • subject - (scalar) the subject element of the message packet
      • body - (scalar) the body element of the message packet
Example Return get_message :
HTTP/1.0 200 (OK) (OK)
Content-Length: 961
Content-Type: text/xml

<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
  <params>
    <param>
      <value>
        <array>
          <data>
            <value>
               <struct>
                  <member>
                    <name>time_stamp</name>
		    <value>
		      <int>20040415203924</int>
		    </value>
		  </member>
		  <member>
		    <name>message_id</name>
		    <value>
		      <int>1</int>
		    </value>
		  </member>
		  <member>
		    <name>subject</name>
		      <value/>
		  </member>
		  <member>
		    <name>body</name>
		    <value>
		      <string>fdfds</string>
		    </value>
		  </member>
		  <member>
		    <name>thread</name>
		    <value/>
		  </member>
		  <member>
		    <name>to_attr</name>
		    <value>
		      <string>tofu@thetofu.com</string>
		    </value>
		  </member>
		  <member>
		    <name>xml</name>
		    <value>
		      <string>
		        &lt;message to='tofu@thetofu.com' from='zorncj@jabber.musc.edu/Home' type='chat'>
			  &lt;body>fdfds&lt;/body>
			&lt;/message>
		      </string>
		    </value>
		  </member>
		  <member>
		    <name>from_attr</name>
		    <value>
		      <string>zorncj@jabber.musc.edu/Home</string>
		    </value>
		  </member>
		  <member>
		    <name>type</name>
		    <value>
		      <string>chat</string>
		    </value>
		  </member>
		  <member>
  		    <name>id</name>
		    <value/>
		  </member>
		</struct>
	     </value>
	   </data>
	 </array>
    </value>
   </param>
  </params>
</methodResponse>

check_message -


get a message that has been sent to you and DO NOT delete it from punjab.

Mode Description

Given all of the required information on a post, it will send a request to the jabber server for any message packets sent to you.

Arguments

  1. [string] (required)
    • sid - punjab session id
  2. [string]
    • to - the to attribute of the message packet you would like to retrieve
  3. [string]
    • type - the type attribute of the message packet you would like to retrieve (error,message,chat,)
  4. [string]
    • id - the id attribute or thread id of the message packet you would like to retrieve
  5. [string]
    • from - the from attribute of the message you would like to retrieve
Example check_message :
POST http://thetofu.com:32080/?session=xmlrpc_client
Accept: text/xml
Accept: multipart/*
Content-Length: 210
Content-Type: text/xml
 
<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
  <methodName>check_message</methodName>
  <params>
    <param>
      <value>
        <string>a7efdsfdfddsf435235c30fdffds95ba42c83eb21c3daa@punjab</string>
      </value>
    </param>
  </params>
</methodCall>

Return Values

  1. [array] - an array of structs is returned
    • [struct]

    • Containing Keys :
      • time_stamp - (int) the time stamp for this message packet
      • status - (scalar) the status element of the message packet
      • to_attr - (scalar) the to attribute of the message packet
      • from_attr - (scalar) the from attribute of the message packet
      • id - (int) the id attribute of the message packet
      • type - (scalar) the type attr of the message packet
      • xml - (scalar) the entire message xml packet
      • thread - (scalar) the thread element of the message packet
      • subject - (scalar) the subject element of the message packet
      • body - (scalar) the body element of the message packet
Example Return check_message :
HTTP/1.0 200 (OK) (OK)
Content-Length: 961
Content-Type: text/xml

<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
  <params>
    <param>
      <value>
        <array>
          <data>
            <value>
               <struct>
                  <member>
                    <name>time_stamp</name>
		    <value>
		      <int>20040415203924</int>
		    </value>
		  </member>
		  <member>
		    <name>message_id</name>
		    <value>
		      <int>1</int>
		    </value>
		  </member>
		  <member>
		    <name>subject</name>
		      <value/>
		  </member>
		  <member>
		    <name>body</name>
		    <value>
		      <string>fdfds</string>
		    </value>
		  </member>
		  <member>
		    <name>thread</name>
		    <value/>
		  </member>
		  <member>
		    <name>to_attr</name>
		    <value>
		      <string>tofu@thetofu.com</string>
		    </value>
		  </member>
		  <member>
		    <name>xml</name>
		    <value>
		      <string>
		        &lt;message to='tofu@thetofu.com' from='zorncj@jabber.musc.edu/Home' type='chat'>
			  &lt;body>fdfds&lt;/body>
			&lt;/message>
		      </string>
		    </value>
		  </member>
		  <member>
		    <name>from_attr</name>
		    <value>
		      <string>zorncj@jabber.musc.edu/Home</string>
		    </value>
		  </member>
		  <member>
		    <name>type</name>
		    <value>
		      <string>chat</string>
		    </value>
		  </member>
		  <member>
  		    <name>id</name>
		    <value/>
		  </member>
		</struct>
	     </value>
	   </data>
	 </array>
    </value>
   </param>
  </params>
</methodResponse>

get_iq -


get iq packets that have been sent to you.

Mode Description

Given all of the required information on a post, it will send a request to the jabber server for any iq packets sent to you.

Arguments

Example get_iq :

Return Values

Example Return get_iq :

send_xml -


send any xml to the jabber server

Mode Description

Arguments

Example send_xml :

Return Values

Example Return send_xml :