venomous0x / WhatsAPI

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

Help in Contest app using whatsapi #958

Open ramapunk opened 10 years ago

ramapunk commented 10 years ago

Hi Folks!

I made a contest app for a tv show using whatsapi. Basically receive a video and ask about their personal data to apply the contest: Name, email, accept disclaimer.

All go fine in the test stage, but today the number has been published on air and people started to send a lot of messages to the contest and the script stop responding. When i try to restart the script returns a "Uncaught exception 'Exception' with message 'Login Failure' " and can't continue.

I think i am banned, but what can i do to prevent this situation on future? The app does not making spam, just respond people who talks to the app to complete the steps in the contest.

Thanks!

alesantosp commented 10 years ago

@ramapunk please see http://www.whatsapp.com/faq/en/general/23154266. In special iten 6. This api is an unofficial client and maybe for this you was blocked.

thiagosantos commented 10 years ago

You did not implement the right way your code! You MUST allways sinc your new contacts, and try to simulate a human behavior with message stats (random composing, writing, pause ... ).

What was your approach about this?

Best regards,

Thiago Santos http://thiagosantos.com

On Mon, Sep 15, 2014 at 4:17 PM, alesantosp notifications@github.com wrote:

@ramapunk https://github.com/ramapunk please see http://www.whatsapp.com/faq/en/general/23154266. In special iten 6. This api is an unofficial client and maybe for this you was blocked.

— Reply to this email directly or view it on GitHub https://github.com/venomous0x/WhatsAPI/issues/958#issuecomment-55643364.

mgp25 commented 10 years ago

It doesn't matter if you sync the contact if the other user haven't synced you.

http://www.whatsapp.com/faq/en/general/28030003

Also the provided link by @alesantosp will the useful to keep in mind this platform is not for spammers!

ramapunk commented 10 years ago

@thiagosantos I figured that not important the sync because the user need add us in their contacts list to send us a message. Now we are implementing the sync process like the example code. Reading in the issues i noticed that i can do it just only a few times per hour. I dont understand why i have to send all the contacts list to sync every time, it not possible send only the new ones?

@alesantosp thanks, we are trying to contact to whatsapp inc to check it out!

@mgp25 we do not make spam. We wait for user actions and react about this. Never we send unsolicited messages.

mgp25 commented 10 years ago

You only send sync when starting up the app and when adding a new contact

ramapunk commented 10 years ago

@mgp25 because new people start talking to the app all the time, and those new contacts must be added. I added now the sync every 21 mins but i dont know if too short period or it's ok!

thiagosantos commented 10 years ago

In my mind and in my implementation, every time someone contact me i should i sync this new number . This is what happens in the phone-to-phone WhatsApp workflow.

Someone add you to his contact list, and then you add he back to your own contact list (with sync).

About human behavior you should send random stats before sending the message itself. like two composing, one pause, composing and then send.

best regards,

Thiago Santos http://thiagosantos.com

On Mon, Sep 15, 2014 at 9:17 PM, ramapunk notifications@github.com wrote:

@mgp25 https://github.com/mgp25 because new people start talking to the app all the time, and those new contacts must be added. I added now the sync every 21 mins but i dont know if too short period or it's ok!

— Reply to this email directly or view it on GitHub https://github.com/venomous0x/WhatsAPI/issues/958#issuecomment-55678832.

alesantosp commented 10 years ago

@ramapunk check #762 about types of sync.

mgp25 commented 10 years ago

@thiagosantos if you do it that way its fine

@ramapunk No, only sync once when starting the script or adding new contact but not every 21 minutes.

The sync method is just to see which of your contacts in your address list have whatsapp, then added automatically to the WhatsApp contacts.

ramapunk commented 10 years ago

@mgp25 if i never do a sync whats happends?

Sync a new contact when they say hello for first time is tricky to me because the flow of new contacts can be one to hundreds per hour depending the scenario. Can i do this?

//in a function who detect the message comes from a new contact
//maybe a dozen of new contacts in minutes
if (user_exists($number)){
    //some code when user are interacting...
}else{
   //first time,  Sync 
   $wa->sendSync($newContactNumber,"delta");  //in this case is better delta?
   //some code welcome message
}

and in the main loop should be scheduled a full sync over 24 hours.

//the script runs 24/7 sends presence and reconnect periodically.
//should add a full sync every 24 hours
$last_day=time();
while(true){
    if((time()-$last_day)>=86400){
        $wa->sendSync(getNumbers());
        $last_day=time();
    }
}

@thiagosantos the human behavior can be fast and random using usleep instead sleep?

foreach ($responseQueue as $number => $message ){
    $wa->sendMessageComposing($number);
    usleep(rand(10000,350000));
    $wa->sendMessagePause($number);
    usleep(rand(23300,155600));
    $wa->sendMessage($number,$message);
    unset($responseQueue[$number]);
}

@alesantosp thanks for the delta mode!

rodrigofaillace commented 10 years ago

Congrats @ramapunk for your contest idea. Do you have any link to that?

Just letting you know, I have tried to reach Whatsapp Inc at bd@whatsapp.com , but no answer has been received. Did you get any?

thiagosantos commented 10 years ago

@ramapunk i should do something like this, with not expected composing status.

foreach ($responseQueue as $number => $message ){
$wa->sendActiveStatus();
for($i=0; $i< rand(1,5); $i++) {
$wa->sendMessageComposing($number); 
usleep(rand(500,5000));
$wa->sendMessagePause($number);
}
$wa->sendMessage($number,$message);
unset($responseQueue[$number]);
}
domingopa commented 10 years ago

better: $w->sendSync($newContactNumber,"delta","background");

mgp25 commented 10 years ago

@ramapunk if you never sync you probably get blocked. You can chat without syncing if the other part is participating in the conversation. Then instead of addind one by one, when you reach X numbers of new contacts you can schedule a sync, almost at startup.

Also the timing between messages dont need to be random values, just a time a human can write messages. For example. I can't send 10 messages to different persons in 2 seconds, thats is considered abusing the system and you will get instant block. So you have to take care of your script behavior.

@rodrigofaillace WhatsApp support support@whatsapp.com

@thiagosantos composing and paused status are optional.

rodrigofaillace commented 10 years ago

@mgp25 thanks. I am trying to reach them.

thiagosantos commented 10 years ago

@mgp25 they can be, but when i say to simulate the behavior I say to be full, like a true cellphone app do. to do that you must use this optional status.

best regards,

Thiago Santos http://thiagosantos.com

On Tue, Sep 16, 2014 at 7:30 PM, mgp25 notifications@github.com wrote:

@ramapunk https://github.com/ramapunk if you never sync you probably get blocked. You can chat without syncing if the other part is participating in the conversation. Then instead of addind one by one, when you reach X numbers of new contacts you can schedule a sync, almost at startup.

Also the timing between messages dont need to be random values, just a time a human can write messages. For example. I can't send 10 messages to different persons in 2 seconds, thats is considered abusing the system and you will get instant block. So you have to take care of your script behavior.

@rodrigofaillace https://github.com/rodrigofaillace WhatsApp support support@whatsapp.com

@thiagosantos https://github.com/thiagosantos composing and paused status are optional.

— Reply to this email directly or view it on GitHub https://github.com/venomous0x/WhatsAPI/issues/958#issuecomment-55823777.