1
0
mirror of https://github.com/thooge/esp32-nmea2000-obp60.git synced 2025-12-13 05:53:06 +01:00

api functions for ci

This commit is contained in:
andreas
2023-09-05 19:44:25 +02:00
parent f6cbcecb78
commit 56b5598c15
3 changed files with 72 additions and 7 deletions

View File

@@ -121,11 +121,18 @@ function getFwHeaders($aheaders=null){
}
return $outHeaders;
}
function getJson($url,$headers=null,$doThrow=false){
function getJson($url,$headers=null,$doThrow=false,$jsonData=null){
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL,$url);
curl_setopt($curl,CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, getFwHeaders($headers));
$outHeaders=getFwHeaders($headers);
if ($jsonData != null){
$json=json_encode($jsonData);
array_push($outHeaders,"Content-Type: application/json");
array_push($outHeaders,"Content-length: ".strlen($json));
curl_setopt($curl, CURLOPT_POSTFIELDS,$json);
}
curl_setopt($curl, CURLOPT_HTTPHEADER, $outHeaders);
$response = curl_exec($curl);
$httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
#echo("curl exec for $url:$response:$httpcode\n");