How to call ejabberdctl from PHP (Apache)
Posted
by Adil
on Stack Overflow
See other posts from Stack Overflow
or by Adil
Published on 2010-03-07T07:17:06Z
Indexed on
2010/04/11
6:23 UTC
Read the original article
Hit count: 344
Hi,
I am trying to call ejabberdctl from PHP but i keep getting an error code of 3 (Failed RPC connection to the node ejabberd@localhost: nodedown).
My PHP script contains the following code to add friends :
exec('sudo /opt/ejabberd-2.1.2/bin/ejabberdctl add_rosteritem adil.baig40122310029739 godudu.com chburaska0822431111022397 godudu.com chburaska0822431111022397 Friends both', $output, $retCode);
exec('sudo /opt/ejabberd-2.1.2/bin/ejabberdctl add_rosteritem chburaska0822431111022397 godudu.com adil.baig40122310029739 godudu.com adil.baig40122310029739 Friends both', $output, $retCode);
I have also added ejabberdctl to /etc/sudoers like so :
# Custom entry for ejabberdctl, so it can be used via PHP
www-data ALL= NOPASSWD: /opt/ejabberd-2.1.2/bin/ejabberdctl
I have also added the ejabberd bin directory to /etc/environment, like so :
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/ejabberd-2.1.2/bin"
source /etc/environment
Everytime i run the PHP script $retCode (the exec return code) returns 3, but if i run the same php file from the command line it works.
Help!
© Stack Overflow or respective owner