Question

I have successfully installed following items as i want to Integrate Facebook Chat Into my web page

Python Punjab Twisted

on my windows XP , but now i want to use strophe library , to connect with Punjab.

Does anyone know how do i use strophe library , as i tried one example listed below supplied in strophe library. The problem is i don't know what to specify in JID and Password field which is being asked by basic.html page.

Note:

  1. as punjab is successfully installed on my windows xp and i am getting XEP-0124 - BOSH response too

  2. Environment is localhost

basic.js

var BOSH_SERVICE = 'http://bosh.metajack.im:5280/xmpp-httpbind'
var connection = null;

function log(msg) 
{
    $('#log').append('<div></div>').append(document.createTextNode(msg));
}

function rawInput(data)
{
    log('RECV: ' + data);
}

function rawOutput(data)
{
    log('SENT: ' + data);
}

function onConnect(status)
{
    if (status == Strophe.Status.CONNECTING) {
    log('Strophe is connecting.');
    } else if (status == Strophe.Status.CONNFAIL) {
    log('Strophe failed to connect.');
    $('#connect').get(0).value = 'connect';
    } else if (status == Strophe.Status.DISCONNECTING) {
    log('Strophe is disconnecting.');
    } else if (status == Strophe.Status.DISCONNECTED) {
    log('Strophe is disconnected.');
    $('#connect').get(0).value = 'connect';
    } else if (status == Strophe.Status.CONNECTED) {
    log('Strophe is connected.');
    connection.disconnect();
    }
}

$(document).ready(function () {
    connection = new Strophe.Connection(BOSH_SERVICE);
    connection.rawInput = rawInput;
    connection.rawOutput = rawOutput;

    $('#connect').bind('click', function () {
    var button = $('#connect').get(0);
    if (button.value == 'connect') {
        button.value = 'disconnect';

        connection.connect($('#jid').get(0).value,
                   $('#pass').get(0).value,
                   onConnect);
    } else {
        button.value = 'connect';
        connection.disconnect();
    }
    });
});

basic.html

<!DOCTYPE html>
<html>
  <head>
    <title>Strophe.js Basic Example</title>
    <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js'></script>
    <script src='../strophe.js'></script>
    <script src='basic.js'></script>
  </head>
  <body>
    <div id='login' style='text-align: center'>
      <form name='cred'>
        <label for='jid'>JID:</label>
        <input type='text' id='jid'>
        <label for='pass'>Password:</label>
        <input type='password' id='pass'>
        <input type='button' id='connect' value='connect'>
      </form>
    </div>
    <hr>
    <div id='log'></div>
  </body>
</html>
Was it helpful?

Solution

I have create an account over here and get JID and Password for free and for localhost , use JID as 'localhost' only and you can leave password blank.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top