Sunday, March 2. 2008PHPurple 0.1.0 pre-alphaTrackbacks
Trackback specific URI for this entry
No Trackbacks
Comments
Display comments as
(Linear | Threaded)
Hi Anatolly,
dropped by Your site yesterday,and a very interesting topic you are working on, jhust currently looking for exactly this kind of application. I am working on a virtual user, which is a PHP script (CMD Line) where You can sent messages to, and which will accept these, save to database (Including emoticons). so this seems to be an ideal way to use PHP to do so. One thing I am currently looking at is the fact, that, when You sent a message to a user, the user will not see the message if it is not in the buddylist. So I would need to have a handler, which will first add the user to the buddylist, and then listen to the messages. Is this already possible in the current status of the code ? I see in debugging that the ADD 0 RL 0 command is being issued. Looking forward, best Greetings from Luxembourg Tom
Hi Tom,
thanks for that positive words. Probably this is what you're looking for: http://phpurple.rubay.de/purpleaccount-addbuddy.html You can already force the script to add unknown users to the buddy list (see this example). Or, if you mean the script should request the blist addition by the real user - it's not yet implemented (but may be it'll work with addBuddy too). Regards, Anatoliy
Hi again Anatoliy
You're welcoem ah this add unknow user seems to be interesting, can You give me a hint how to do it (see this example
Tom,
the example is right on this page if(!$buddy || is_string($buddy)) { $account = $conversation->getAccount(); $b = new PurpleBuddy($account, $conversation->getName() ? $conversation->getName() : $buddy); $account->addBuddy($b); PurpleBuddyList::addBuddy($b); } Regards, Anatoliy
Okay cool, I will give it a try tomorrow, have the wrong notebook with me.
Thanks a lot ! Will keep You up2date with the process Tom
Hi again,
I jhust tried your code, but it does not seem to add the buddy, so when I have a new MSN id and I add the script-buddy, it still appears as offline. here the debugging: 11:13:35) msn: S: NS 000: ADD 0 RL 0 xxx@yyy.lzz xxx@yyy.zz (11:13:35) msn: xxx@yyy.zz has added you to his or her buddy list. But no action on the PHP Script Any Idea ? Thanks Tom
Tom,
did you looked in the xml (or have you ever set the user dir up)? I'v tried the same things - the script adds the buddy to the blist. Changing the status of the account is unfortunately not implemented yet. So, in this case, you can still write and send messages, but are not able to change the status. Logging in with the script account and changing the status could work, i suppose. If you don't set up some user dir, i think, all the changes will only be work within a single session. Regards Anatoliy
hi,
i've tired to compile and got pcre.h error. had to change the include from pcre/pcrelib/pcre.h to pcre.h only. i am not sure if this is a special case for me. cheers, f make test fails and now i am sleepy =) btw good stuff!!
Do you have PHP headers or PHP dev package installed? I'm trying to use the PCRE version which comes with PHP. Obviously, you have the PCRE dev package on you system, which was found when you changed the include. I wrote no tests yet, if you'll write a one, send it to me.
Hi.
I tried your PHPurple..This is cool stuff..I could compile successfully..and tried your sample code..but this sample code seems not to become online.Since I cannot find this client on my buddy lists in MSN Live Messenger client. and I need more sample code example in your documents.I will play with PHPurple more.. For example,I want the sample code the followings: Simple send messages and receive messages.
Are you using two accounts, which are already in the each other's contact lists?
You could try to add the buddy to the account's blist first, or instantiate the conversation within PurpleClient::onSignedOn, which is called, when the account gets online (see the corresponding classes/methods in the reference)
Thank you for your reply.
I'm using two accounts and both account has each account on buddy list. I've thought that when I run your sample,I can see another account becomes online..but actually,I couldn't see the account. Then I just added some strings and "flush();ob_flush();" on each functions in php script.I notice loopCallback() function is executed only once.. Sorry to tell you my environment early.I tell you my situation more.. I'm using php-5.2.5 on FreeBSD 6.1. and execute like this. $ php -f purple.php Here is my executed script: // purple.php class CustomPurpleClient extends PurpleClient{ private $someVar; private $someOtherVar; protected function initInternal(){ $this->someVar = "Hello World"; $this->someOtherVar = time(); echo "initInternal\n"; flush();ob_flush(); } protected function writeIM($conversation,$buddy,$message,$flags,$time){ if(PurpleClient::MESSAGE_RECV==$flags){ printf("(%s) %s %s: %s\n", $conversation->getName()?$conversation->getName():$buddy->getName(), date('H:i:s',$time), is_object($buddy)?$buddy->getAlias():$buddy, $message ); } echo "writeIM\n"; flush();ob_flush(); } protected function writeConv($convesation,$buddy,$message,$flags,$time){ echo "writeConv\n"; flush();ob_flush(); } protected function loopCallback(){ echo "loop callback, doing something just before the loop starts\n"; flush();ob_flush(); } protected function onSignedOn($connection){ print $this->justForFun($this->someVar); flush();ob_flush(); } protected function justForFun($param){ return "just for fun, the param is : $param"; } } try{ $user_dir = "/tmp/purple-test"; if(!file_exists($user_dir)||!is_dir($user_dir)){ mkdir($user_dir); } PurpleClient::setUserDir($user_dir); PurpleBuddyList::load(); $client = CustomPurpleClient::getInstance(); $client->addAccount("msn://xxx@live.jp:my_password@messenger.hotmail.com:1863"); $client->connectToSignal("signed-on"); $client->runLoop(); flush();ob_flush(); }catch(Exception $e){ echo "[Purple]".$e->getMessage()."\n"; exit(); } and the output is here: initInternal loop callback, doing something just before the loop starts // and then kept silent..and then stop with Ctrl+C If you can give me more advice,please let me know.
In my script,$client->addAccount didn't return anything.
but addAccount should return object. I don't know why?and I traced a little. var_dump($client->addAccount("msn://xxx@live.jp:my_password@messenger.hotmail.com:1863")); I traced like this: // purple.c 680: accounts = purple_accounts_get_all(); +681:{ +682:GList *iter; +683:for(iter=accounts;iter;iter=iter->next){ +684:PurpleAccount *account = iter->data; +685:fprintf(stdout,"account=%s\n",purple_account_get_username(account)); +686:} +687:} and added fprintf(stdout,"return_value=%d\n",return_value); after zend_update_property_long(); the output is here: account=xxx@live.jp
Kazuhiro,
I think I've figured out, why the script's account don't gets online. I've just added the script's account to the pidgin and enabled it. And then I see, that the other account isn't authorized by the script's account yet. So hm, it's my ommission and it'll be one of the next features i'll be must to implement. Now, if you simply authorize the other account, while logged in the script's account with pidgin, it should work. If you wanna more details to this, see account.h from the libpurple's source. regards Anatoliy
Kazuhiro,
you're right, with PurpleClient::addAccount it's my ommission too. Actually it returns void ... so I should either write void in the doc, or make the method return PurpleAccount, which was added. Are you registered at sf.net? The forum and tracker there would be more comfortable than this comments. Regards Anatoliy
Hi.
Thank you to tell me in detail..I will see account.h later..I was reading finch/finch.c and tried to make a small sample code..but it failed once..and i will try on monday..it's holiday in jp... but I don't know whether I can make this sample or not...since I didn't understand about libpurple,yet..and running cycle..Anyway,I will try more..so give me a few days to try again. I've just register my account on sf.net..so I would post comment at the forum on next time. Thanks again..and happy holiday!! Regards kazuhiro
I've tried PHPurple on my debian-4.0 with apache-2.2.8, PHP-5.2.5, Pidgin-2.3.1, PHPurple 0.1.0 pre-alpha. It's work properly. i tried the function loopCallback() only started before runLoop(), isn't it? Is there anyway to make loopCallback loop continuously? so, in this function i put script for sending messages automatically or check the buddy continuously. Like trigger function. I also tried with PHP5.3 but it didn't work. Cannot load purple.so: undefined symbol: php_pcre_free.
Thank you, Regards, Arnas Risqianto
Arnas,
thanks for trying it. the loopCallback() has only sense, if you calling runLoop(), because it's being automatically called within runLoop(). So, this mechanism gives an ability to run things at the moment, where the main loop starts (such for example a tick function). runLoop() shouldn't be invoked within apache because it forks. things like while(1){} will not work, because the whole thing is basing on the glib, which needs its g_main_loop_run() for the events exchange regards anatoliy
i've tried with code like this:
..... protected function writeIM($conversation, $buddy, $message, $flags, $time) { echo "writeIM\n"; } protected function loopCallback() { echo "loopCallback()\n"; register_tick_function("testloop"); declare(ticks=1); } protected function onSignedOn($connection) { echo "SignedOn\n"; } function testloop(){ echo "testLoop\n"; sleep(1); } ... after signOn, function testloop() stop, and if i send IM to this buddy, the function writeIM() called once and the function testloop() start loop again. the function writeIM() stop and can't do callback. the output like this: loopCallback() testLoop testLoop SignedOn testLoop writeIM() testLoop testLoop testLoop testLoop testLoop testLoop .... how to make the function testloop() looping continuously and also the function writeIM() can be work properly like usually?
thanks for your fast response.
i've tried with code like this: ..... protected function writeIM($conversation, $buddy, $message, $flags, $time) { echo "writeIM\n"; } protected function loopCallback() { echo "loopCallback()\n"; register_tick_function("testloop"); declare(ticks=1); } protected function onSignedOn($connection) { echo "SignedOn\n"; } function testloop(){ echo "testLoop\n"; sleep(1); } ... after signOn, function testloop() stop, and if i send IM to this buddy, the function writeIM() called once and the function testloop() start loop again. the function writeIM() stop and can't do callback. the output like this: loopCallback() testLoop testLoop SignedOn testLoop writeIM() testLoop testLoop testLoop testLoop testLoop testLoop .... how to make the function testloop() looping continuously and also the function writeIM() can be work properly like usually? Regards Arnas Risqianto
I've tried your example yesterday ... hm, it seems to be bad. Somehow php staff conflicts with glib ... I'll try to implement the glibs g_timeout_add in the next version. At the moment I think the best way could be to check things conditionally on the events.
How to check things conditionally on the events? Can you give me the sample code?
Did you ever tried PHP Jabber Client (http://code.blitzaffe.com/pages/phpclasses/files/jabber_client_52-11) ? It's using event-driven model. I think this is good idea for the next version of PHPhurple like this model. Also it have function handleHeartbeat() that called periodically by the Jabber class to allow us to do our own processing. This is very important function. Thanks.
i mean for example when a message is comming in etc., you can call you function ... the libpurple is event driven as well ... many class methods are callbacks (as for example writeIM), but they aren't user defined ... say, they are already defined but only work, if implemented, ... the heartbeat method ... yeah, i'll try to implement it with glibs timeout things in the next version ... who could it know about that things with tick functions ...
yeah it's easy for handle incoming message. For ex: in function writeIM() we can put code for insert the message to the database. but for handling outgoing message? i want to create an application for send and receive message base on database.as far as i know, for handling outgoing message is using triggered callback that automatically check from the database. and if there are any message ready to send, then send it through writeIM(). isn't it?
yeah, you're right here - for this schema such a timer simply necessary. i thought all the time only in the terms of a normal im client, where the messages come live from the user ...
i've already checked out the glib g_timeout_add callback, it works ... so soon we will have such a heartbeat method there ... first i must finish a couple of other reported bugs ... so stay tuned ...
printf("c1\n");
if(NULL == zend_objects_get_address(PURPLE_G(purple_php_client_obj))) { printf("c2\n"); (...) } printf("c3\n"); when i run CustomPurpleClient::getInstance(); output is c1 Aborted what's problem? please help [ubuntu 8.04]
sorry for delayed answer... the only one thing i see here - you should use php_printf instead of printf ...
привет.
никак не могу отправить сообщение определенному пользователю... по идее это должен делать класс PurpleConversation. Пример прекрасно работает и на hi отвечает. Если можно пример кода. Заранее спасибо)
вот то что нужно
http://phpurple.rubay.de/purpleconversation-sendim.html
Манул перечитан много раз)
посмотри пожалуйста, может я уже просто ничего не понимаю. Я пишу следующий код: protected function onSignedOn($connect) { print "signed-on!\n"; $acc = $connect->getAccount(); $conv = new PurpleConversation(1,$acc,"203186152"); $conv->sendIM("reg erg erg reg erg ergrg rg "); }
Попробовал послать сообщение по XMPP используя тот же код, получилось =)
Возможно причина только в icq
ок,
спасибо за интерес ... мануал к сожалению оставляет желать лучшего ... вобще, в оскаре вроде бы и неавторизированные клиенты должны работать ... хм .. хотя наверное зависит от конкретного клиента тоже
Hi Anatoliy,
I m already able to let the script successfully connect to MSN, but I have a problem. Always when I send a msg to the script account from any other account the script always aborts when the sender is not in the script accounts buddy list. Do you know why that is? Here is the log from the moment I send the msg to the script account. ------------------------------------------------------------------------- (11:29:21) msn: S: NS 000: RNG 1744776633 207.46.27.56:1863 CKI 116189154.228176155 senderaccount@xxxxxxx.com XXXX (11:29:21) msn: new httpconn (0x84da8e8) (11:29:21) dns: DNS query for '207.46.27.56' queued (11:29:21) dns: Created new DNS child 24258, there are now 1 children. (11:29:21) dns: Successfully sent DNS request to child 24258 (11:29:21) dns: Got response for '207.46.27.56' (11:29:21) dnsquery: IP resolved for 207.46.27.56 (11:29:21) proxy: Attempting connection to 207.46.27.56 (11:29:21) proxy: Connecting to 207.46.27.56:1863 with no proxy (11:29:21) proxy: Connection in progress (11:29:21) proxy: Connected to 207.46.27.56:1863. (11:29:21) msn: C: SB 001: ANS 1 scriptaccount@xxxxxxx.com 116189154.228176155 1744776633 (11:29:21) msn: S: SB 001: IRO 1 1 1 senderaccount@xxxxxxx.com XXXX (11:29:21) msn: S: SB 001: ANS 1 OK (11:29:22) msn: S: SB 001: MSG senderaccount@xxxxxxx.com XXXX 129 Aborted ------------------------------------------------------------------------ When the sender is in the script accounts buddy list, it works find. It displays the msg correctly and the script also sends a reply if you e.g. send "hi" to it. Could that be a bug with libpurple? thanks, Friedrich
i have done installation on RHEL 5.3, but when i browse it on web page.
Warning: dl() [function.dl]: Unable to load dynamic library './phurple.so' - ./phurple.so: cannot open shared object file: No such file or directory in /var/www/html/phurple.php on line 5 EXTENSION PHURPLE NOT FOUND ON THE SYSTEM Fatal error: Class 'PhurpleClient' not found in /var/www/html/phurple.php on line 17
Is possible service a status from any Im ?
example : user aaaa@hotmail.com change status from available to not available For me interesting that when I'm using PhurpleClient::setDebug(true); I see (09:03:29) blist: Updating buddy status for sysdan84@hotmail.com (MSN) Is possible to know when user is change? thanks a lot Daniel |
CategoriesQuicksearch |