-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsigfox_backend_message_test.php
More file actions
37 lines (29 loc) · 997 Bytes
/
Copy pathsigfox_backend_message_test.php
File metadata and controls
37 lines (29 loc) · 997 Bytes
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
<?php
$url = 'https://backend.sigfox.com/api/devices/{device-id}/messages'; // put your device-id
// init, username & passwd
$curl = curl_init();
$login = 'xxxxxxxxxxxxxxxxxxxxxxxx'; // from your Api access
$pass = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; // from your Api access
// set up
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPGET, true);
//curl_setopt($curl, CURLOPT_COOKIESESSION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY); // Need SSL
curl_setopt($curl, CURLOPT_USERPWD,"$login:$pass");
// store data
$data = curl_exec ($curl);
// open file and write data
$fl = fopen('sigfoxMsg.json','a'); // write json file sigfoxMsg.json for test
{ fwrite($fl, $data);
fclose($fl);
}
// displaying data
$json_url = "http://yoururl/sigfoxMsg.json";
$json = file_get_contents($json_url);
$data = json_decode($json, TRUE);
echo "<pre>";
print_r($data);
echo "</pre>";
curl_close($curl);
?>