venomous0x / WhatsAPI

Interface to WhatsApp Messenger
2.6k stars 2.13k forks source link

Send broadcast message #636

Open nk19 opened 10 years ago

nk19 commented 10 years ago

hi, i have a company and about 200 people add my phone number in their phone now i want to use this api to send a broadcast message to all of them but when i try its now working only if i send to 20 of them its working but not for big anount of people i realy need that and i know that you can send with the phone to 250 people at once is there any way to sand like that with this api..?

eslamo commented 10 years ago

hi, first you must think about your issue here.. you have 200 numbers and you can only send for 20 each time. so first you must have an array of all your numbers then split it into 10 arrays and send to each array of them individually.

you can use a function like this to split the main array into small arrays

/**
* Array split - Split array in $pieces
*
* @param array
* @param int - Number of pieces
* @return array - Split array (multidimensional)
*/
function array_split($array, $pieces=2)
{
     // Less then 2 pieces?
     if ($pieces < 2){
         return array($array);
     }
    $newCount = ceil(count($array)/$pieces);
    $a = array_slice($array, 0, $newCount);
    $b = $this->array_split(array_slice($array, $newCount), $pieces-1);
    return array_merge(array($a),$b);
}
nk19 commented 10 years ago

thanks for this answer, but this is not what answer my question...

i wanted to know if someone can give access to send broadcast messages the same way you sand from the phone. up to 250 persons at the time and not up to 20;

can someone did it, or know how to and can do it..??

i think that this is the only thing that missing in this butifule api///

thanks :+1:

shirioko commented 10 years ago

Yes that did answer your question.

You can only send a broadcast message to up to 20 people at a time. So to reach 250 people you'll need to send 13 broadcasts.

nk19 commented 10 years ago

so why when you send from the device it anable you to send directly to 250 ? i closed this by mistake... can i reopen this issue..?

shirioko commented 10 years ago

No you can't send to 250 directly using the app on your device. WhatsApp supports up to 50 broadcast recipients (not 20, my bad):

tx  <iq id="getproperties-1395752061-1" type="get" xmlns="w" to="s.whatsapp.net">
tx    <props></props>
tx  </iq>

rx  <iq from="s.whatsapp.net" id="getproperties-1395752061-1" type="result">
rx    <props version="1">
        ...
rx      <prop name="broadcast" value="50"></prop>
        ...
rx    </props>
rx  </iq>
nk19 commented 10 years ago

i have friends that sending broadcasts to more then 200 people at once try to add to a broadcast list on your phone users and you will see that the limit is about 256+-

so how it work for them..? and can you see if there is any way to sand like from the device..?

jonnywilliamson commented 10 years ago

@shirioko

Actually on my iphone it shows the ability of up to 50 Broadcast LISTS, and in each list, 256 people can be added.

Iphone/Android/windows phone difference?

nk19 commented 10 years ago

this is what i said. so how we can bring it to work with php..?

shirioko commented 10 years ago

@jonnywilliamson can you show me what that list management looks like?

jonnywilliamson commented 10 years ago

Sure. Will email to save me hidding private info in screen shots....

nk19 commented 10 years ago

thanks for all the help and time!!!

shirioko commented 10 years ago

Looks to me like the app just sends the same message to multiple lists

$lists = array(
    array("4324325423", "234234234234"),
    array("4634543", "453454543", "436354355"),
    etc.
}

foreach($lists as $list)
{
     $w->sendMessageBroadcast($list, $message);
}

@jonnywilliamson thanks, got it!

nk19 commented 10 years ago

so the app on the mobile phone is also limited to 50 but it split the 256 selected numbers to 6 arrays? if that was the case why not limit to 250.. i think that they do give the option to send directly to 250 but just need to find how