venomous0x / WhatsAPI

Interface to WhatsApp Messenger
2.59k stars 2.14k forks source link

Binding problem #1172

Open shivaburade opened 8 years ago

shivaburade commented 8 years ago

i am trying to bind onGetMessage and onGetGroupsSubject but it seems nothing is happening

it would be better if someone show example of simple binding of onGetGroupsSubject or onGetGroupsInfo etc.

this is how i bind the events

<?php require '../src/whatsprot.class.php'; require '../src/events/MyEvents.php'; $username = "mynumber"; //Mobile Phone prefixed with country code so for india it will be 91xxxxxxxx $password = "mypassword";

function Message($mynumber, $from, $id, $type, $time, $name, $body) { echo "Message from $name:\n$body\n\n"; }

function asunto($phone, $from, $author, $msgid, $type, $time, $name, $message) { echo "Group name: " . $type; }

$w = new WhatsProt($username, 0, "WhatsApp Messaging", true); //Name your application by replacing "WhatsApp Messaging"

$events = new MyEvents($w); $w->eventManager()->bind("onGetMessage", "Message"); $w->eventManager()->bind("onGetGroupsSubject","asunto"); $w->connect(); $w->loginWithPassword($password);

while($w->pollMessage()); //$w->sendGetRequestLastSeen($target); ?>

WHAnonymous commented 8 years ago

@shvburade use this instead: https://github.com/WHAnonymous/Chat-API

shivaburade commented 8 years ago

if i have defined onGetMessage event, so will it be called automatically when when i use pollMessage because poll message returns all the new message

function Message($mynumber, $from, $id, $type, $time, $name, $body) { echo "Message from $name:\n$body\n\n"; }

$w = new WhatsProt($username, 0, "WhatsApp Messaging", true); //Name your application by replacing "WhatsApp Messaging"

$events = new MyEvents($w); $w->eventManager()->bind("onGetMessage", "Message"); $w->connect(); $w->loginWithPassword($password); while($w->pollMessage());

shivaburade commented 8 years ago

in documentation i found one event called OngetMessage and one function getMessages()?

if i use getMessages() will it call the ongetMessage or not? pollmessage() and getmessages() which one is used to bind ongetMessage event?

i think pollmessage() returns only one new message whereas getmessages() returns the array of all new message?

WHAnonymous commented 8 years ago

@shvburade use this repo to ask: https://github.com/WHAnonymous/Chat-API