-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.php
27 lines (18 loc) · 1.57 KB
/
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
<?php
$data = array("name" => "Robot", "msg" => "Hi guys, I'm a PHP bot !", "room" => "Room Manarola");
$data_string = json_encode($data);
$ch = curl_init('http://localhost:8080/send/helloFromPhp');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
// small improvements suggested by [email protected]
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
// grab URL and pass it to the browser
echo curl_exec($ch)."\n";
// close cURL resource, and free up system resources
curl_close($ch);
?>