From e65763cdd4cee2944dc0412278ea16edc4bfed45 Mon Sep 17 00:00:00 2001 From: Sintbert Date: Thu, 13 Dec 2018 11:56:35 +0100 Subject: [PATCH 1/2] Add PHP example for a Push method PHP example for a Push method. If i had this it would have saved me 5 hours just to find that it has to be JSON encoded. --- PHP/index.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/PHP/index.php b/PHP/index.php index 85567da..f07461f 100644 --- a/PHP/index.php +++ b/PHP/index.php @@ -37,7 +37,7 @@ // Create RESTClient object -- for help: https://github.com/tcdent/php-restclient $api = new RestClient([ 'base_url' => $RestBaseUrl, - 'headers' => ['Authorization' => 'Bearer '.$token], + 'headers' => ['Authorization' => 'Bearer '.$token, 'Content-Type' => 'application/json', 'Accept' => 'application/json'], ]); //Make an API call to the MiX Integrate server @@ -46,4 +46,13 @@ //Display the result - will need to parse if($result->info->http_code == 200) print_r($result->decode_response()); -?> \ No newline at end of file +?> + +//Example of an API call using PUSH with parameters to get the latest position of a vehicle. +$assetId = 0123456789012345678; +$result = $api->push("/api/positions/assets/latest/1", , json_encode([$assetId])); // Parameters have to be JSON-Encoded. + +//Display the result - will need to parse +if($result->info->http_code == 200) + print_r($result->decode_response()); +?> From ce4d68e9fe5924ba5452e0fc03501e8cc308589a Mon Sep 17 00:00:00 2001 From: Sintbert Date: Thu, 28 Mar 2019 10:57:12 +0100 Subject: [PATCH 2/2] remove overlooked ?> in middle of code remove overlooked ?> in middle of code --- PHP/index.php | 1 - 1 file changed, 1 deletion(-) diff --git a/PHP/index.php b/PHP/index.php index f07461f..c05e01f 100644 --- a/PHP/index.php +++ b/PHP/index.php @@ -46,7 +46,6 @@ //Display the result - will need to parse if($result->info->http_code == 200) print_r($result->decode_response()); -?> //Example of an API call using PUSH with parameters to get the latest position of a vehicle. $assetId = 0123456789012345678;