From 38f5ab2a1eaa941f4e50861ad7852f21711ca2a7 Mon Sep 17 00:00:00 2001 From: Chris Navas Date: Thu, 5 Nov 2015 16:22:56 +0100 Subject: [PATCH 1/2] php example put --- PHP/php-client-http-put.php | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 PHP/php-client-http-put.php diff --git a/PHP/php-client-http-put.php b/PHP/php-client-http-put.php new file mode 100644 index 0000000..2b54853 --- /dev/null +++ b/PHP/php-client-http-put.php @@ -0,0 +1,46 @@ +'home.temp.indoor', + 'timestamp'=> time(), + 'value'=> rand(20, 35), + 'tags'=> [ + 'source'=>'dht22' + ] + ], + [ + 'metric'=>'home.temp.outdoor', + 'timestamp'=> time(), + 'value'=> rand(5, 25), + 'tags'=> [ + 'source'=>'dht22' + ] + ] +] +; + + + +$curl = curl_init($end_point); +curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); +curl_setopt($curl, CURLOPT_USERPWD, $token_id.":".$token_key); //Your credentials goes here +curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); +curl_setopt($curl, CURLOPT_VERBOSE, false); +curl_setopt($curl, CURLOPT_HEADER, false); +curl_setopt($curl, CURLOPT_POST, true); +curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data)); +curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); //IMP if the url has https and you don't want to verify source certificate + +$curl_response = curl_exec($curl); +curl_close($curl); + From 3e67dfae45161e46b75ad0b4fb5f8661c0d69f6e Mon Sep 17 00:00:00 2001 From: Chris Navas Date: Thu, 5 Nov 2015 17:20:44 +0100 Subject: [PATCH 2/2] ajout README.md --- PHP/README.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 PHP/README.md diff --git a/PHP/README.md b/PHP/README.md new file mode 100644 index 0000000..267c103 --- /dev/null +++ b/PHP/README.md @@ -0,0 +1,6 @@ +## IoT PAAS API put php functions. + +### Put + + $ php php-client-http-put.php +