-
Notifications
You must be signed in to change notification settings - Fork 78
/
contactsync.php
executable file
·53 lines (42 loc) · 969 Bytes
/
contactsync.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
set_time_limit(30);
require_once '../src/whatsprot.class.php';
$username = $_GET['phone'];
$password = $_GET['pass'];
$u = $_GET['u'];
if (!is_array($u)) {
$u = [$u];
}
$numbers = [];
foreach ($u as $number) {
if ($number[0] != '+') {
//add leading +
$number = "+$number";
}
$numbers[] = $number;
}
//event handler
/**
* @param $result SyncResult
*/
function onSyncResult($result)
{
foreach ($result->existing as $number) {
echo "$number exists<br />";
}
foreach ($result->nonExisting as $number) {
echo "$number does not exist<br />";
}
die(); //to break out of the while(true) loop
}
$wa = new WhatsProt($username, 'WhatsApp', false);
//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->pollMessage();
}