Closed vibhoo closed 9 years ago
function onGetGroupMessage($phone, $from, $author, $msgid, $type, $time, $name, $message)
{
echo "Group name: " . $name;
}
That function doesn't work, it will give you the name of the sender & message (if you want) not the 'group name'
I need 'group name' (group subject)
This one for example...? Please take time to read the API code, read the wiki too, you will find useful information.
function onGetGroupsSubject($phone, $gId, $time, $author, $participant, $name, $subject){
echo "Group name: ". $subject;
}
Yeah that function also but still I am not getting 'group name'. I think this function is never called up
Here is what I am doing.Let me know what I am doing wrong
function asunto($phone, $gId, $time, $author, $participant, $name, $subject)
{
echo "Group name: ". $subject;
}
$w = new WhatsProt($username, $token, $nickname, $debug);
$w->eventManager()->bind("onGetGroupsSubject","asunto");
$w->Connect();
$w->loginWithPassword($password);
$w->PollMessages();
It's because of this:
if ($node->getAttribute('type') == "subject") {
print_r($node);
$reset_from = explode('@', $node->getAttribute('from'));
$reset_author = explode('@',$node->getAttribute('author'));
$this->eventManager()->fireGetGroupsSubject(
$this->phoneNumber,
reset($reset_from),
$node->getAttribute('t'),
reset($reset_author),
reset($reset_author),
$node->getChild(0)->getAttribute('name'),
$node->getChild(2)->getData()
);
}
I did not try it. When get a message with the attribute subject, it will fire the event. Let's do a thing, post here a sample debug of a message group and ill try to see if its fire or not
Yeah I also figured out the same thing, for message group I am able to send message & receive message
What else you need
I need to see the debug output when you receive group messages.
Getting NULL when trying this
$w = new WhatsProt($username, $token, $nickname, false); // tried with true & false both getting same output
$res = $w->eventManager()->bind("onGetGroupSubject","asunto");
var_dump($res);
For onGetGroupMessage function also I am getting NULL
$res = $w->eventManager()->bind("onGetGroupMessage","ongrpMessage");
var_dump($res);
Why you do that? Its not the way you supose to use it
Then what's the proper way to you it ? I am new to this Just lemme know how should i proceed
$w = new WhatsProt($username, $identity, $nickname, $debug);
$res = $w->eventManager()->bind("onGetGroupMessage","ongrpMessage");
var_dump($w);
object(WhatsProt)#1 (25) { ["accountInfo":protected]=> NULL ["challengeFilename":protected]=> string(17) "nextChallenge.dat" ["challengeData":protected]=> NULL ["debug":protected]=> bool(true) ["event":protected]=> object(WhatsAppEvent)#4 (0) { } ["groupList":protected]=> array(0) { } ["identity":protected]=> string(52) "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ["inputKey":protected]=> NULL ["outputKey":protected]=> NULL ["groupId":protected]=> bool(false) ["lastId":protected]=> bool(false) ["loginStatus":protected]=> string(12) "disconnected" ["mediaFileInfo":protected]=> array(0) { } ["mediaQueue":protected]=> array(0) { } ["messageCounter":protected]=> int(1) ["messageQueue":protected]=> array(0) { } ["name":protected]=> string(8) "xxxxxxx" ["newMsgBind":protected]=> bool(false) ["outQueue":protected]=> array(0) { } ["password":protected]=> NULL ["phoneNumber":protected]=> string(12) "91xxxxxxxxxxx" ["reader"]=> object(BinTreeNodeReader)#3 (2) { ["input":"BinTreeNodeReader":private]=> NULL ["key":"BinTreeNodeReader":private]=> NULL } ["serverReceivedId":protected]=> NULL ["socket":protected]=> NULL ["writer":protected]=> object(BinTreeNodeWriter)#2 (2) { ["output":"BinTreeNodeWriter":private]=> NULL ["key":"BinTreeNodeWriter":private]=> NULL } } Sender name: xxxxx\nGroup Message: Ghjj
Edit your comment, you shared your number and identity with us
Okay Thanks I have edited, Anyways that was a testing no.
Now back to main question, How to get the Group Name(Group Subject) ? any clue or help from your side ?
Yes, i have how is the message node, once i see how it is, i can see if its working or not, if not ill make a fix, i haven't had time to work on this yet.
You need to call sendGetGroupInfo to trigger the onGetGroupSubject event
@shirioko can you please tell me how to use it any example/snippet of code will work for me as I am new to Php
$gjid is the group jid
$w->sendGetGroupsInfo($gjid)
$w = new WhatsProt($username, $identity, $nickname, $debug);
$res = $w->sendGetGroupsInfo($groupId);
var_dump($res);
I am doing like this still no success getting exception 'Socket Error'
@vibhoo can you try and practice with /test/whatsapp.php and /examples/exapleFunctional.php before trying to do your own scripts...
I tried those scripts I am able to Send & Receive Message to a Number & Even I am able to Receive Message of a group just what I want to do is to get the Group Name
--> here
Once you call that function, it will fire the event. You only need the group jid. Also how to obtain the group jid has already been answered, so you can search in the issue tracker :)
dera Friends, Is there any way to Post the message to the WhatsApp group using API?
I am using onGetGroupMessage(); to get the messages from the groups but, How would I get the name of the group(s)
Help me I am stuck