venomous0x / WhatsAPI

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

Contact Sync issue #870

Open taiws89 opened 10 years ago

taiws89 commented 10 years ago

Hi guys, I encounter the problem as listed below when I execute contact sync function:

image

My code for sync contact function as below:

<?php
$PATH_PARAM = "/home/whatsapp/bin/bwm_param.php";   //bwm_param.php already included "require_once("whatsprot.class.php" line

require_once($PATH_PARAM);

$u = $argv[1];

if(!is_array($u))
{
    $u = array($u);
}
$numbers = array();
foreach($u as $number)
{
    if(substr($number, 0, 1) !=  "+")
    {
        //add leading +
        $number = "+$number";
    }
    $numbers[] = $number;
}

//event handler
/**
 * @param $result SyncResult
 */
function onSyncResult($result)
{
    foreach($result->existing as $number)
    {
    $number = str_replace("@s.whatsapp.net", "", $number);
        print $number." exists. \n";
    }
    foreach($result->nonExisting as $number)
    {
        print $number." does not exist. \n";
    }
    die();//to break out of the while(true) loop
}

$wa = new WhatsProt($userPhone, $userIdentity, $userName, $debug);

//bind event handler
$wa->eventManager()->bind('onGetSyncResult', 'onSyncResult');

$wa->connect();
$wa->loginWithPassword($password);

//send dataset to server
$wa->sendSync($numbers);

//wait for response
while(true)
{
    $wa->pollMessages();
}

can anyone help me with this?? Many thanks.

CashCode commented 10 years ago

I guess author made something like script-kiddie protection for sync function, this function even doesn't have documentation, by default it sends sync in registration mode. Nobody wants to tell about it.

shirioko commented 10 years ago

Yes it's a very super duper secret kept for many generations.

Make sure you're using the latest code.

taiws89 commented 10 years ago

Hi guys, thanks for replies. Actually I'd tried to run the script again after several hours and it worked again until I run the script for several times, around 100 times continuously, the issue occurred again. Can someone explain what's the error code means?

mgp25 commented 10 years ago

The one explained above or a backoff time..?

CashCode commented 10 years ago

Sat, 09 Aug 2014 11:40:49 -0700 от mgp25 notifications@github.com:

The one explained above or a backoff time..? — Reply to this email directly or view it on GitHub . Backoff time means the time between syncs. I dont know what type and when they do it, but they can send messages avoiding ban. 

shirioko commented 10 years ago

Context=background allows you to sync up to 4 times per hour, Interactive & Registrations is limited to 50 times per hour. If you exceed those limits you will receive the back-off error

prasenjeetp commented 10 years ago

@shirioko : can you please explain what the Context is about. How is Background different from Interactive from Registrations. How many numbers can we sync in each context type per call.

mgp25 commented 10 years ago

@prasenjeetp here are now updating and giving support here: https://github.com/mgp25/WhatsAPI-Official

Registration Sync is made when you just registered your number with WhatsApp all your contacts are going to be synced. It will check if there is any contact to sync (background) and interactive when you add a contact using WhatsApp it automatically send Sync to that contact.