so I have been working on this code and I cant put my finger on it I am using php to send data to firebase. this one send the data how I want it but any data that I already have in it erases it instead of updating it how I want.
$url = 'https://granted-7cdeb.firebaseio.com/maps.json';
$arr = array($mapId =>array($bike =>array("coords"=>array("latitude"=>$lat, "longitude"=>$lng), "orientation"=>$ori,
"timestamp"=>$time)));
$data_string = json_encode($arr);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PATCH");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
echo $result = curl_exec($ch);
and this is the result I receive when I execute this code
{"2":{"suzuki":{"coords":{"latitude":32.6990593,"longitude":-117.0279802},"orientation":259.61241243675,"timestamp":1536138065}}}
when I try it this way
$url = 'https://granted-7cdeb.firebaseio.com/maps.json';
$arr = array($mapId =>array($bike =>array("coords"=>array("latitude"=>$lat, "longitude"=>$lng), "orientation"=>$ori,
"timestamp"=>$time)));
$data_string = json_encode($arr);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
echo $result = curl_exec($ch);
it uploads multiple arrays but instead of updating its lat and lng it creates a name and upload multiple times
{"name":"-LLcxfR1R7w2j5FcWhdA"}
please help me I am trying to accomplish sending a array of this nature
{"2":{"suzuki":{"coords":{"latitude":32.6990593,"longitude":-117.0279802},"orientation":259.61241243675,"timestamp":1536138065}}}
I have a website that tracks a users location and send it to my firebase table MAPS then I plot the user location so they can view each others location.