1

I'm trying to upload spherical images on street view using Publish Api. Upload of image data and place association works well, but whenever i try to upload heading and gps position data to the image server responds "OK" but then no heading nor position were associated to the image.

Here is the php code i use for the last step of info upload, i really don't know where i am wrong.

$data['uploadReference']['uploadUrl']=$upload_url;
$data['pose']['heading']=$heading_north;      
$data['pose']['latLngPair']=$latLngPair;    
$data['captureTime']['seconds']=time();    
$data['places']['placeId']=$placeid; 

$data_string = json_encode($data); 


$ch = curl_init('https://streetviewpublish.googleapis.com/v1/photo?key='.$_GOOGLE_API['api_key']);

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                             
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);     
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  
curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                     
  'authorization: Bearer '.$_GOOGLE_API['access_token'],
  'Content-Type: application/json',                                             
  'Content-Length: ' . strlen($data_string))                                     
);                                                                                                                   
$result = curl_exec($ch);

curl_close ($ch);

EDIT:

I've implemented the second step as suggested but nothing changes.. Curl response still doesn't contains any error..

$ch = curl_init('https://streetviewpublish.googleapis.com/v1/photo/'.$photo_id.'?key='.$_GOOGLE_API['api_key'].'&updateMask=pose.heading');                                                                      
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");                                                                     
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);  
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
        'authorization: Bearer '.$_GOOGLE_API['access_token'],
        'Content-Type: application/json',                                                                                
        'Content-Length: ' . strlen($data_string))                                                                       
    );                                                                                                                                                                                                                                   
$json_response=curl_exec($ch);
curl_close ($ch);
echo $json_response;

EDIT2: this procedure works but google apis are slow and edited data will show up in minutes..

EDIT3 (SOLVED): GET photos (list) has some chache issue. to get the correct value just updated you need to request GET photo (single) to force an effective cache update.

recursio
  • 13
  • 6

1 Answers1

1

Try to set the values in a second step with photo.update. Don't forget to set the updateMask for the values.

Thomas
  • 514
  • 4
  • 14
  • I've implemented the second step as suggested but nothing changes.. see edit in main question – recursio Sep 01 '17 at 13:45
  • How do you check the pose data? With a photo.get request? – Thomas Sep 01 '17 at 14:02
  • I check data by a GET photos request to get a list of photos and associated data. – recursio Sep 01 '17 at 14:15
  • image metadata has now changed to a configuration i've previusly uploaded.. is it only so slow to apply changes maybe? – recursio Sep 01 '17 at 14:21
  • 1
    It depends. Sometimes the changes show up in 5 minutes, sometimes it takes 24 hrs. Occasionally the changes are even lost, and you need to submit it again. – Thomas Sep 04 '17 at 08:29
  • So google publish api is slow and unstable: cool! I noticed also that my last changes sometimes show up after i submit a new change and then i have to submit another change to see the last one. This "feature" makes the api unusable and this is very sad to me. – recursio Sep 04 '17 at 08:45