-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimessage_api.php
50 lines (37 loc) · 1.01 KB
/
imessage_api.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
<?php
//TEST: http://localhost/imessage.php?telephone=+421911123543&message=TEST
// +421xxx international format
$tel = urlencode($_GET["telephone"]);
//message
$message = $_GET["message"];
//echo "t: " .$tel . "m: " . $message . "//";
/* generate reqUID */
function random() {
return (float)rand()/(float)getrandmax();
}
$random = "0000".(random()*pow(36,4) << 0);
$yo = base_convert($random, 10, 36);
$reqUID = substr($yo, -4);
//echo $reqUID;
/******************/
//Quick example to send hello:
//hashid = TELEPHONE NUMBER
//recipients = empty
//file-name = empty
//text = text
$post_data = array(
'hashid' => $tel,
'reqUID' => $reqUID,
'recipients' => '',
'file-name' => '',
'text' => $message,
);
$url = 'http://192.168.1.16:333/sendMessage.srv';
$curl = curl_init();
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
$response = curl_exec($curl);
print($response);
?>