/
test.php
31 lines (27 loc) · 840 Bytes
/
test.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
<?php
$APEserver = 'http://ape.local.ape-project.org:6969/?';
$APEPassword = 'testpasswd';
$messages = array(
'Test Message',
'<span style="color: #800">I\'m awesome!</span>',
'<span style="color: #080">Hey, how are you doing?</span>',
);
$cmd = array(array(
'cmd' => 'inlinepush',
'params' => array(
'password' => $APEPassword,
'raw' => 'postmsg',
'channel' => 'testchannel',
'data' => array( //Note: data can't be a string
'message' => $messages[array_rand($messages)]
)
)
));
var_dump($APEserver.rawurlencode(json_encode($cmd)));
$data = file_get_contents($APEserver.rawurlencode(json_encode($cmd)));
$data = json_decode($data);
if ($data[0]->data->value == 'ok') {
echo 'Message sent!';
} else {
echo 'Error sending message, server response is : <pre>'.$data.'</pre>';
}