I'm having some issues with the Streetview Publish API through PHP, attempting to replicate the procedure listed under "Uploading a photo" in the documentation
https://developers.google.com/streetview/publish/first-app
I've got the first part working and can retrieve the upload URL to a variable $upload_url.
This is my code for step 2
$another = array(
'upload-file' => curl_file_create($imagepath)
);
$header = array (
"Authorization: Bearer $accesstoken",
"Content-Type: multipart/form-data"
);
$options = array(
CURLOPT_URL => $upload_url,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $another,
CURLOPT_HTTPHEADER => $header,
CURLOPT_SSL_VERIFYPEER => false
);
$ch = curl_init();
curl_setopt_array($ch, $options);
$response = curl_exec($ch);
echo(curl_error($ch));
curl_close($ch);
var_dump($response);
curl_error
is not returning anything, and $response
returns true, so I am assuming the file was properly uploaded.
For step 3, I'm using
$data['uploadReference']['uploadUrl']=$upload_url;
$data['pose']['latLngPair']['latitude']=$latitude;
$data['pose']['latLngPair']['longitude']=$longitude;
$data['captureTime']['seconds']=$timestamp;
$data_string = json_encode($data);
print_r($data);
$ch = curl_init('https://streetviewpublish.googleapis.com/v1/photo?key='.$apikey);
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 '.$accesstoken,
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);
curl_close ($ch);
If I var_dump($result)
I get a 404 suggesting that the uploaded file isn't at the uploadUrl
Array ( [uploadReference] => Array ( [uploadUrl] => https://streetviewpublish.googleapis.com/media/user/XXXX/photo/YYYY ) [pose] => Array ( [latLngPair] => Array ( [latitude] => 53.59398125 [longitude] => -1.95349941 ) ) [captureTime] => Array ( [seconds] => 1502560132 ) ) string(255)
"{
"error": {
"code": 404,
"message": "The upload reference cannot be found. Please make sure you have uploaded a file to the upload reference URL. If this error persists, request a new upload URL and try again.",
"status": "NOT_FOUND"
}
} "
Any advice would be welcome, my instinct is that the issue is with the second step rather than the third, but I'm open to all suggestions. Thanks in advance.
I also encountered this error when I tried uploading panorama pictures.
It seems that you are not uploading a correct 360 photo. Make sure that the 360 picture you are uploading has metadata. You may download this ExifTool to check the image.
I've got a similar problem in PHP with curl lib at step 2. Replacing curl-php with a server side call resolved for me but you need to know full file path i.e.:
here is my step 2:
The server is some sort of cloud hosted Linux system.. hope this helps.