I have googled this a lot and not found a single piece of answer....!
I am using whatsapi to send messages with PHP.
However, when i execute any of the functions including loginwithpassword() or sendmessage() it outputs respones with lines starting with tx. I want to integrate the api into my webiste and auto post certain inputs to some of my Whatsapp groups.
I use the following code
$username = "91xxxxxxxx"; //Mobile Phone prefixed with country code so for india it will be 91xxxxxxxx
$password = "Password";
$identity = strtolower(urlencode(sha1($username, true)));
$w = new WhatsProt($username, $identity, "WhatsApp Messaging", true); //Name your application by replacing "WhatsApp Messaging"
$w->connect();
$w->loginWithPassword($password);
$phone="91xxxxxxxxxxx";
$w->eventManager()->bind("onGetGroups", "onGetGroups");
$w->sendGetGroups();
function onGetGroups($phone,$groups)
{
echo "<form action='' method='POST'>";
foreach($groups as $gr){
echo "<input type='checkbox' name='gids[]' value='$gr[id]'>$gr[id] -> $gr[subject]<br>";
}
echo "<textarea name='msg' rows='10' cols='40'></textarea>";
echo "<input type='submit' name='gmsub' value='Send Group Message'>";
echo "</form>";
}
if(isset($_POST['gmsub'])){
$msg=$_POST['msg'];
$groupc=$_POST['gids'];
$total=count($groupc);
for($i=0;$i<$total;$i++){
$gId=$groupc[$i];
$w->sendMessage($gId, $msg);
}
}
I dont want the outputs like the following on my screen...
tx <stream:features>
tx <readreceipts></readreceipts>
tx <groups_v2></groups_v2>
tx <privacy></privacy>
tx <presence></presence>
tx </stream:features>
tx <auth mechanism="WAUTH-2" user="91xxxxxxxxxx">&£ºƒ91xxxxxxxxxn•Vv^¹ðÁ2EÎòƒ³oΡ1447256662</auth>
rx <start from="s.whatsapp.net"></start>
rx <stream:features></stream:features>
rx <challenge>œÇÚ‰C¹WŒ™`¼%1Á™</challenge>
tx <response>ó gÏD’—!°¶µpOðµ³ @³XH2înÆ/•[r</response>
rx <success t="1447256780" props="4" kind="free" status="active" creation="1413023053" expiration="1476095053">9Ož¦n»ÃFáG¨È{'sÊM‚</success>
.................etc
I want to output only what i want on the screen. How do I suppress the tx and rx outputs on screen ?!
Turn off the DEBUG mode by changing the last parameter in first line false
instead of true