2012-01-24 53 views
0

我已經成功安裝了以下項目,因爲我想整合Facebook聊天進入我的網頁如何使用的strophe與XMPP或Pujab

的Python 旁遮普 扭曲

在我的Windows XP,但現在我想使用strophe庫,連接旁遮普邦。

是否有人知道我如何使用strophe庫,因爲我試過下面列出的 strophe庫中提供的一個示例。問題是我不知道要在basic.html頁面要求的JID和密碼字段中指定什麼。

注:

  1. 如成功安裝在我的Windows XP旁遮普邦和我得到XEP-0124 - BOSH反應過於

  2. 環境爲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> 

回答

1

我有超過here創建一個帳戶,並獲得JID和密碼免費 和本地主機,使用JID只爲 'localhost' 的並且您可以將密碼留空。

相關問題