librelist archives

« back to archive

Questions re PreBinding & autologin

Questions re PreBinding & autologin

From:
Barry Brinster
Date:
2014-08-22 @ 00:36
I have some questions about adding PreBinding and auto-login to
converse.

I have an ejabberd server, and our converse demo works with the standard
login form.

I have installed and configured XMPP Prebind for PHP, and it is spitting
out the jid, sid, and rid.

All of that happens on tbis page -- prebind.php --  and the vars are
mapped in javascript as follows:

var chat = {
	"jid" : "<?php echo $sessionInfo['jid']; ?>",
	"sid" : "<?php echo $sessionInfo['sid']; ?>",
	"rid" : "<?php echo $sessionInfo['rid']; ?>"
};

Where I'm stuck is bringing everything together, and getting Converse to
load.

On the page where I want to initiate Converse, I'm calling
converse.min.js and the following JSON...

$.getJSON('http-bind/prebind.php', function (chat) {
    converse.initialize({
        prebind: true,
        bosh_service_url: 'http://oh22.aljex.com/http-bind/',
        jid: chat.jid,
        sid: chat.sid,
        rid: chat.rid,
        debug: true
    });
});

But the values from  the prebind page -- chat.jid, chat.sid, and
chat.rid -- are not coming in.

When I inspect the page, I just get what I pout in...


$.getJSON('http-bind/prebind.php', function (chat) {
    converse.initialize({
        prebind: true,
        bosh_service_url: 'http://oh22.aljex.com/http-bind/',
        jid: chat.jid,
        sid: chat.sid,
        rid: chat.rid,
        debug: true
    });
});

How can I get the jid, sid and rid into the coverse.initialize?

Or am I missing something entirely?

Re: [conversejs] Questions re PreBinding & autologin

From:
Jc Brand
Date:
2014-08-22 @ 08:59
On Thu, Aug 21, 2014 at 05:36:15PM -0700, Barry Brinster wrote:
> I have some questions about adding PreBinding and auto-login to
> converse.
> 
> I have an ejabberd server, and our converse demo works with the standard
> login form.
> 
> I have installed and configured XMPP Prebind for PHP, and it is spitting
> out the jid, sid, and rid.
> 
> All of that happens on tbis page -- prebind.php --  and the vars are
> mapped in javascript as follows:
> 
> var chat = {
> 	"jid" : "<?php echo $sessionInfo['jid']; ?>",
> 	"sid" : "<?php echo $sessionInfo['sid']; ?>",
> 	"rid" : "<?php echo $sessionInfo['rid']; ?>"
> };
> 
> Where I'm stuck is bringing everything together, and getting Converse to
> load.
> 
> On the page where I want to initiate Converse, I'm calling
> converse.min.js and the following JSON...
> 
> $.getJSON('http-bind/prebind.php', function (chat) {
>     converse.initialize({
>         prebind: true,
>         bosh_service_url: 'http://oh22.aljex.com/http-bind/',
>         jid: chat.jid,
>         sid: chat.sid,
>         rid: chat.rid,
>         debug: true
>     });
> });
> 
> But the values from  the prebind page -- chat.jid, chat.sid, and
> chat.rid -- are not coming in.
> 
> When I inspect the page, I just get what I pout in...
> 
> 
> $.getJSON('http-bind/prebind.php', function (chat) {
>     converse.initialize({
>         prebind: true,
>         bosh_service_url: 'http://oh22.aljex.com/http-bind/',
>         jid: chat.jid,
>         sid: chat.sid,
>         rid: chat.rid,
>         debug: true
>     });
> });

prebind.php should return a JSON object, which contains the jid, sid and rid,
because you call it with the getJSON method.

So make sure that this is the case.

You can also put a breakpoint inside the callback function (in which you call
converse.initialize) and check what the value of "chat" is.

Check whether it has jid, sid and rid values and what those values are.

Regards
JC

Re: [conversejs] Questions re PreBinding & autologin

From:
Barry Brinster
Date:
2014-08-23 @ 21:15
This is in my prebind.php file...

var chat = {
	"jid" : "<?php echo $sessionInfo['jid']; ?>",
	"sid" : "<?php echo $sessionInfo['sid']; ?>",
	"rid" : "<?php echo $sessionInfo['rid']; ?>"
}

And when I load and inspect that file, I get (for example)...

{
	"jid" : "barry@xmpp.XXXXXXX.com/webclient",
	"sid" : "bb39c492765dfae2f419c03c0ef6cfe65445fc00",
	"rid" : "3257010358"
};

Based on your sample in the Converse documentation, I'm trying to get
these values from the prebind.php file with this call...

$.getJSON('prebind.php', function (chat) {
    converse.initialize({
        prebind: true,
        bosh_service_url: 'http://oh22.aljex.com/http-bind/',
        jid: chat.jid,
        sid: chat.sid,
        rid: chat.rid,
        debug: true
    });
});

But when I inspect, the I just see "data.jid, data.sid, data.rid" and
not the values.

I tried adding alert(chat); right after getJSON and nothing alerts, so
there must be an issue.

Must be more involved in extracting the vars?

Sorry, I do not have any experience in JSON.


> -------- Original Message --------
> Subject: Re: [conversejs] Questions re PreBinding & autologin
> From: JC Brand <lists@opkode.com>
> Date: Fri, August 22, 2014 4:59 am
> To: conversejs@librelist.com
> 
> 
> On Thu, Aug 21, 2014 at 05:36:15PM -0700, Barry Brinster wrote:
> > I have some questions about adding PreBinding and auto-login to
> > converse.
> > 
> > I have an ejabberd server, and our converse demo works with the standard
> > login form.
> > 
> > I have installed and configured XMPP Prebind for PHP, and it is spitting
> > out the jid, sid, and rid.
> > 
> > All of that happens on tbis page -- prebind.php --  and the vars are
> > mapped in javascript as follows:
> > 
> > var chat = {
> > 	"jid" : "<?php echo $sessionInfo['jid']; ?>",
> > 	"sid" : "<?php echo $sessionInfo['sid']; ?>",
> > 	"rid" : "<?php echo $sessionInfo['rid']; ?>"
> > };
> > 
> > Where I'm stuck is bringing everything together, and getting Converse to
> > load.
> > 
> > On the page where I want to initiate Converse, I'm calling
> > converse.min.js and the following JSON...
> > 
> > $.getJSON('http-bind/prebind.php', function (chat) {
> >     converse.initialize({
> >         prebind: true,
> >         bosh_service_url: 'http://oh22.aljex.com/http-bind/',
> >         jid: chat.jid,
> >         sid: chat.sid,
> >         rid: chat.rid,
> >         debug: true
> >     });
> > });
> > 
> > But the values from  the prebind page -- chat.jid, chat.sid, and
> > chat.rid -- are not coming in.
> > 
> > When I inspect the page, I just get what I pout in...
> > 
> > 
> > $.getJSON('http-bind/prebind.php', function (chat) {
> >     converse.initialize({
> >         prebind: true,
> >         bosh_service_url: 'http://oh22.aljex.com/http-bind/',
> >         jid: chat.jid,
> >         sid: chat.sid,
> >         rid: chat.rid,
> >         debug: true
> >     });
> > });
> 
> prebind.php should return a JSON object, which contains the jid, sid and rid,
> because you call it with the getJSON method.
> 
> So make sure that this is the case.
> 
> You can also put a breakpoint inside the callback function (in which you call
> converse.initialize) and check what the value of "chat" is.
> 
> Check whether it has jid, sid and rid values and what those values are.
> 
> Regards
> JC

Re: [conversejs] Questions re PreBinding & autologin

From:
Jc Brand
Date:
2014-08-25 @ 08:32
It looks like you aren't returning a proper JSON encoded response from
prebind.php.

That's probably why there is no alert inside getJSON, because the 
"success" callback
(the one with converse.initialize inside) doesn't get called. I'd bet the "error"
callback gets called instead, but there is no function specified for it.

 $.getJSON is shorthand for $.ajax with dataType="JSON". To debug, you can change
 $.getJSON to $.ajax (setting dataType="JSON") and then specify an error callback
together with the existing success callback. Then put a breakpoint inside the
error callback.

See:
http://api.jquery.com/jquery.getjson/
http://api.jquery.com/jquery.ajax/

But before you do that, make 100% sure that you are actually returning JSON
encoded data from prebind.php. Apparently its as simple as using the built-in
function "json_encode".

Regards
JC
On Sat, Aug 23, 2014 at 02:15:21PM -0700, Barry Brinster wrote:
> This is in my prebind.php file...
> 
> var chat = {
> 	"jid" : "<?php echo $sessionInfo['jid']; ?>",
> 	"sid" : "<?php echo $sessionInfo['sid']; ?>",
> 	"rid" : "<?php echo $sessionInfo['rid']; ?>"
> }
> 
> And when I load and inspect that file, I get (for example)...
> 
> {
> 	"jid" : "barry@xmpp.XXXXXXX.com/webclient",
> 	"sid" : "bb39c492765dfae2f419c03c0ef6cfe65445fc00",
> 	"rid" : "3257010358"
> };
> 
> Based on your sample in the Converse documentation, I'm trying to get
> these values from the prebind.php file with this call...
> 
> $.getJSON('prebind.php', function (chat) {
>     converse.initialize({
>         prebind: true,
>         bosh_service_url: 'http://oh22.aljex.com/http-bind/',
>         jid: chat.jid,
>         sid: chat.sid,
>         rid: chat.rid,
>         debug: true
>     });
> });
> 
> But when I inspect, the I just see "data.jid, data.sid, data.rid" and
> not the values.
> 
> I tried adding alert(chat); right after getJSON and nothing alerts, so
> there must be an issue.
> 
> Must be more involved in extracting the vars?
> 
> Sorry, I do not have any experience in JSON.
> 
> 
> > -------- Original Message --------
> > Subject: Re: [conversejs] Questions re PreBinding & autologin
> > From: JC Brand <lists@opkode.com>
> > Date: Fri, August 22, 2014 4:59 am
> > To: conversejs@librelist.com
> > 
> > 
> > On Thu, Aug 21, 2014 at 05:36:15PM -0700, Barry Brinster wrote:
> > > I have some questions about adding PreBinding and auto-login to
> > > converse.
> > > 
> > > I have an ejabberd server, and our converse demo works with the standard
> > > login form.
> > > 
> > > I have installed and configured XMPP Prebind for PHP, and it is spitting
> > > out the jid, sid, and rid.
> > > 
> > > All of that happens on tbis page -- prebind.php --  and the vars are
> > > mapped in javascript as follows:
> > > 
> > > var chat = {
> > > 	"jid" : "<?php echo $sessionInfo['jid']; ?>",
> > > 	"sid" : "<?php echo $sessionInfo['sid']; ?>",
> > > 	"rid" : "<?php echo $sessionInfo['rid']; ?>"
> > > };
> > > 
> > > Where I'm stuck is bringing everything together, and getting Converse to
> > > load.
> > > 
> > > On the page where I want to initiate Converse, I'm calling
> > > converse.min.js and the following JSON...
> > > 
> > > $.getJSON('http-bind/prebind.php', function (chat) {
> > >     converse.initialize({
> > >         prebind: true,
> > >         bosh_service_url: 'http://oh22.aljex.com/http-bind/',
> > >         jid: chat.jid,
> > >         sid: chat.sid,
> > >         rid: chat.rid,
> > >         debug: true
> > >     });
> > > });
> > > 
> > > But the values from  the prebind page -- chat.jid, chat.sid, and
> > > chat.rid -- are not coming in.
> > > 
> > > When I inspect the page, I just get what I pout in...
> > > 
> > > 
> > > $.getJSON('http-bind/prebind.php', function (chat) {
> > >     converse.initialize({
> > >         prebind: true,
> > >         bosh_service_url: 'http://oh22.aljex.com/http-bind/',
> > >         jid: chat.jid,
> > >         sid: chat.sid,
> > >         rid: chat.rid,
> > >         debug: true
> > >     });
> > > });
> > 
> > prebind.php should return a JSON object, which contains the jid, sid and rid,
> > because you call it with the getJSON method.
> > 
> > So make sure that this is the case.
> > 
> > You can also put a breakpoint inside the callback function (in which you call
> > converse.initialize) and check what the value of "chat" is.
> > 
> > Check whether it has jid, sid and rid values and what those values are.
> > 
> > Regards
> > JC