JAXL is an open source Jabber XMPP Client library written in PHP. It provides a self titled class JAXL which implements XMPP protocol. It can be extended to write custom event handler for every message or presence received. Developers are using JAXL for developing real time applications. Checkout 5 exciting gaming bots you can make using JAXL.
However one thing which goes un-noticed is that JAXL can also be used to import Gtalk contacts of any user. This is infact one of the very first thing which JAXL class do, after successful authentication with the Gtalk servers i.e. import the authenticated user contact list. In this blog post I will demo a sample script to import any user contact list from google servers.
Importing Gtalk contacts using JAXL
- Download and extract jaxl-1.0.4.rar
- Edit
config.ini.phpand update credentials of the user whose contact list we are trying to import:$key = array("prod"=>array("user"=>"mailsforabhinav", "pass"=>"xxxxxx", "host"=>"talk.google.com", "port"=>5222, "domain"=>"gmail.com" ), - Open
jaxl.class.phpand modify the code as below:function setStatus() { // Set a custom status or use $this->status $this->sendStatus($this->status); print "Setting Status...\n"; print_r($this->rosterlist); // Print the contact list on the console print "Done\n"; exit; } - Finally run from command line to retrieve gtalk contacts of the authenticated user.
php index.php
One can easily modify the above code to save user contacts in a database.
Also one can echo json_encode($this->rosterlist) in response to an Ajax call from the browser.
Enjoy and leave your comments.
Abhi's Weblog is a collection of blog articles written by
Hi Abhi,
Thanks for sharing your work with us but i have one question related to this.
Its related to point no 2.
Edit
config.ini.phpand update credentials of the user whose contact list we are trying to import:How can we get the credentials of other users?
For e.g. i have a gmail friend whose id is abc@gmail.com
I want to import gtalk contacts of abc using jaxl how can i provide password for abc in config.ini file.
Please guide me on this.
Thanks,
Pankaj
Reply
Abhinav Singh
Hi Pankaj,
I guess you are looking for something like this:
1. A user enters his credentials for importing the friends.
2. You pass the credentials to Jaxl library.
3. You get back the response from library in form of json data.
4. Save/Display them as per your requirement.
Regarding how to pass user credentials to Jaxl, you will need to tweak the code a little bit. e.g. You can call the script using system command and pass arguments. Inside the script you read them as $argv[1], $argv[2], etc.
Hope this helps.
Abhinav
Hi Abhinav,
I repeated the same steps as you suggested but I am getting following error
PHP Warning: fopen(log/logger.log): failed to open stream: No such file or directory in C:\wamp\www\jaxl\logger.class.php on line 51
Warning: fopen(log/logger.log): failed to open stream: No such file or directory in C:\wamp\www\jaxl\logger.class.php on line 51
PHP Warning: fwrite() expects parameter 1 to be resource, boolean given in C:\wamp\www\jaxl\logger.class.php on line 52
Warning: fwrite() expects parameter 1 to be resource, boolean given in C:\wamp\www\jaxl\logger.class.php on line 52
PHP Warning: fclose() expects parameter 1 to be resource, boolean given in C:\wamp\www\jaxl\logger.class.php on line 53
Warning: fclose() expects parameter 1 to be resource, boolean given in C:\wamp\www\jaxl\logger.class.php on line 53
PHP Warning: fopen(log/logger.log): failed to open stream: No such file or directory in C:\wamp\www\jaxl\logger.class.php on line 51
Warning: fopen(log/logger.log): failed to open stream: No such file or directory in C:\wamp\www\jaxl\logger.class.php on line 51
PHP Warning: fwrite() expects parameter 1 to be resource, boolean given in C:\wamp\www\jaxl\logger.class.php on line 52
Warning: fwrite() expects parameter 1 to be resource, boolean given in C:\wamp\www\jaxl\logger.class.php on line 52
PHP Warning: fclose() expects parameter 1 to be resource, boolean given in C:\wamp\www\jaxl\logger.class.php on line 53
Warning: fclose() expects parameter 1 to be resource, boolean given in C:\wamp\www\jaxl\logger.class.php on line 53
PHP Warning: fopen(log/logger.log): failed to open stream: No such file or directory in C:\wamp\www\jaxl\logger.class.php on line 51
Warning: fopen(log/logger.log): failed to open stream: No such file or directory in C:\wamp\www\jaxl\logger.class.php on line 51
PHP Warning: fwrite() expects parameter 1 to be resource, boolean given in C:\wamp\www\jaxl\logger.class.php on line 52
Warning: fwrite() expects parameter 1 to be resource, boolean given in C:\wamp\www\jaxl\logger.class.php on line 52
PHP Warning: fclose() expects parameter 1 to be resource, boolean given in C:\wamp\www\jaxl\logger.class.php on line 53
Warning: fclose() expects parameter 1 to be resource, boolean given in C:\wamp\www\jaxl\logger.class.php on line 53
PHP Warning: fopen(log/logger.log): failed to open stream: No such file or directory in C:\wamp\www\jaxl\logger.class.php on line 51
Warning: fopen(log/logger.log): failed to open stream: No such file or directory in C:\wamp\www\jaxl\logger.class.php on line 51
PHP Warning: fwrite() expects parameter 1 to be resource, boolean given in C:\wamp\www\jaxl\logger.class.php on line 52
Warning: fwrite() expects parameter 1 to be resource, boolean given in C:\wamp\www\jaxl\logger.class.php on line 52
PHP Warning: fclose() expects parameter 1 to be resource, boolean given in C:\wamp\www\jaxl\logger.class.php on line 53
Warning: fclose() expects parameter 1 to be resource, boolean given in C:\wamp\www\jaxl\logger.class.php on line 53
Starting TLS Encryption…
PHP Warning: stream_socket_enable_crypto(): this stream does not support SSL/crypto in C:\wamp\www\jaxl\xmpp.class.php on line 348
Warning: stream_socket_enable_crypto(): this stream does not support SSL/crypto in C:\wamp\www\jaxl\xmpp.class.php on line 348
PHP Warning: fopen(log/logger.log): failed to open stream: No such file or directory in C:\wamp\www\jaxl\logger.class.php on line 51
Warning: fopen(log/logger.log): failed to open stream: No such file or directory in C:\wamp\www\jaxl\logger.class.php on line 51
PHP Warning: fwrite() expects parameter 1 to be resource, boolean given in C:\wamp\www\jaxl\logger.class.php on line 52
Warning: fwrite() expects parameter 1 to be resource, boolean given in C:\wamp\www\jaxl\logger.class.php on line 52
PHP Warning: fclose() expects parameter 1 to be resource, boolean given in C:\wamp\www\jaxl\logger.class.php on line 53
Warning: fclose() expects parameter 1 to be resource, boolean given in C:\wamp\www\jaxl\logger.class.php on line 53
Reply
Abhinav Singh
Alright, fix this by replacing log/logger.log by /full/path/to/log/logger.log. That should fix your problem.
Also SSL error is seen meaning either it is not enable or is not configured properly. Read this for proper some previous discussion on this issue: http://code.google.com/p/jaxl/issues/detail?id=7
sameer
Hi Abhi,
Thanks for replying.
giving the full path to logger solved the one problem. But still I am getting the SSL error.
I tried both solution on that thread
i.e
stream_socket_enable_crypto($this->stream, TRUE,
STREAM_CRYPTO_METHOD_SSLv3_CLIENT);
or
if (!stream_socket_enable_crypto($this->stream, TRUE,
STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
stream_socket_enable_crypto($this->stream, TRUE,
STREAM_CRYPTO_METHOD_SSLv3_CLIENT);
}
but still smae result.
Starting TLS Encryption…
Warning: stream_socket_enable_crypto() [streams.crypto]: this stream does not support SSL/crypto in C:\wamp\www\jaxl\xmpp.class.php on line 349
Fatal error: Maximum execution time of 60 seconds exceeded in C:\wamp\www\jaxl\xmpp.class.php on line 162
I am using wamp and using the default configuration for php and apache. Do you have any idea how to fix it?
THanks in advance
Abhinav Singh
Try this from command line:
php -i | grep openssl
Or since you are on windows, see the output of phpinfo() command and check if you have openssl enabled with php. If not do it and problem should get fixed. Hopefully
sameer
Hi,
Thanks
I looked at the output of phpinfo() and I cna see
OpenSSL support disabled (install ext/openssl).
I am using wamp. I checked the ext directory in php folder of wamp but I could ifnd any dll which is similar to openssl. Do u know how to enable it? I un commented extension=php_openssl.dll line in php.ini but it didn’t work. DO I need to install anything?
by the way is it necessary to have openssl enable to communicated with gtalk?
Abhinav Singh
Go to php.net and download the required dll for your version of PHP and enable it.
I am getting the SSL error.
phpinfo ()
opensslOpenSSL support enabled
OpenSSL Version OpenSSL 0.9.8a 11 Oct 2005
Warning: stream_socket_enable_crypto(): this stream does not support SSL/crypto
in D:\jabber\SGBot\xmpp.class.php on line 348
[xmpp.class.php][348]
Warning: stream_socket_enable_crypto(): this stream does not support SSL/crypto
in D:\jabber\SGBot\xmpp.class.php on line 348
plz help
Reply
Abhinav Singh
Kindly read my replies to sameer above. You seem to be missing the same things.
clif
OpenSSL support enabled
My WEB Server supported SSL protocol
but exist that ERROR
Abhinav Singh
php -i | grep openssl
Run this from command line and see if you have openssl enabled for cli. Enabling for your webserver will not make jaxl work
clif
I have this web-server TopServer 2.1
In this package exists 3 php*.exe )
php.exe – main console
php-win.exe
php-cgi.exe
then i run *php -i | grep openssl* in php*.exe, result are anything
samir
for me its not working somehow.
its not able to connect to gtalk
Trying to connect at talk.google.com:5222
2009-12-29 09:56:51
Failed to establish a connection at talk.google.com:5222
Abhinav Singh
@Clif,
I have no experience with TopServer. Nevertheless, running jaxl only requires a PHP installation and no web server. I hope you are trying to run jaxl bot through command line.
@samir
What env are you on? Have you updated the config file with your gtalk username and passwords?
Abhinav Singh
I have tested Jaxl on various platform including windows, mac, ubuntu, debian, freebsd and RHEL. If you have your env right, it SHOULD work
Probably checkout closed and known issues here http://code.google.com/p/jaxl/issues/list in case you missed anyone of them.
clif
But my command console hes output:
D:\jabber\SGBot>T:\usr\local\PHP\php.exe D:\jabber\SGBot\index.php
Included module bash.mod.php
Included module feedback.mod.php
Included module md5.mod.php
Starting TLS Encryption…
Warning: stream_socket_enable_crypto(): this stream does not support SSL/crypto
in D:\jabber\SGBot\xmpp.class.php on line 348
don’t like that http://jaxl.googlecode.com/issues/attachment?aid=-4264766588276847936&name=jabb.png&inline=1
Abhinav Singh
Hey clif, just curious any luck while working with jaxl, did it worked for you?
Hi Abhinav,
Thank you very much, sharing your knowledge. I learn new things from this article.
Reply