微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Google街景发布API错误代码=> 400消息=>图片上传网址与所需格式不匹配 [状态] => INVALID_ARGUMENT

如何解决Google街景发布API错误代码=> 400消息=>图片上传网址与所需格式不匹配 [状态] => INVALID_ARGUMENT

我需要Google街景发布API的支持。我在上传缝合的全景照片时收到401数组([错误] =>数组([代码] => 400 [消息] =>照片上传网址与所需格式不匹配。[状态] => INVALID_ARGUMENT))。请给我参考

<?PHP
 $access_token = $_GET['access_token'];
 $cur_upload_url = curl_init();
 curl_setopt_array($cur_upload_url,array(
 CURLOPT_URL => "https://streetviewpublish.googleapis.com/v1/photo:startUpload? 
 key=AIzaXXXXPDrlfiF7slFVjuDDGMAdwtOpUWcedew3",CURLOPT_RETURNTRANSFER => true,CURLOPT_ENCODING => "",CURLOPT_CUSTomrEQUEST => "POST",CURLOPT_HTTPHEADER => array(
 "authorization: Bearer $access_token","content-type: application/json","Content-Length: 0"
    ),));

  $response = curl_exec($cur_upload_url);
  $re = '/https?:\/\/[^"]*/';
  $str = $response;
  preg_match($re,$str,$matches,PREG_OFFSET_CAPTURE,0);
  $upload_url = $_SESSION['UploadRef'] = $matches[0][0];
  $imagePath = "/IMG_7779_Panorama.jpg";
  $file_name_with_full_path = $_SERVER['DOCUMENT_ROOT'].$imagePath;

  $cmd = exec('curl --request POST \--url "'. $upload_url .'" \--upload-file 
  "'.$file_name_with_full_path.'" \--header "Authorization: Bearer '. $access_token .'" ');

  $latVal = 22.7355728;
  $langVal = 88.46367;
  $time_stamp = time();

  $curl_Meta = curl_init();

  curl_setopt_array($curl_Meta,array(
    CURLOPT_URL => "https://streetviewpublish.googleapis.com/v1/photo? 
    key=AIzaSyDqNXXXXfiF7slFVjuDDGMAdwtOpUWredsc",CURLOPT_POSTFIELDS => '{
                "uploadReference":
                {
                  "uploadUrl": "'.$upload_url.'"
                },"pose":
                 {
                   "heading": 95.0,"latLngPair":
                   {
                     "latitude": '.$latVal.',"longitude": '.$langVal.'
                   }
                },"captureTime":
                {
                  "seconds":  '.$time_stamp.'
                },}',CURLOPT_HTTPHEADER => array(
      "authorization: Bearer $access_token","referer : http://mywebsite.com/view_360.PHP",),));


   $response_Meta = curl_exec($curl_Meta);
   $response_json = json_decode($response_Meta,true);
   print_r($response_json);
   die;

   if(curl_errno($curl_Meta)){
    // this would be your first hint that something went wrong
    die('Couldn\'t send request: ' . curl_error($curl_Meta));
  }else{
    //check the HTTP status code of the request.
    $resultStatus = curl_getinfo($curl_Meta,CURLINFO_HTTP_CODE);
    if($resultStatus != 200){
      die('Request Failed: HTTP status code: ' . $resultStatus);
    }else{
      $photoID = $response_json['photoId']['id'];
      //insert google publish information into db table

     }

   }
   curl_close($curl_Meta);
  ?>

我保持规则流畅-

  1. 我在Google Developers Console中创建了一个项目,并获取了授权凭据,因此我的应用程序可以提交API请求。

  2. 然后实施了OAuth 2.0授权。

  3. 照片需要使用Photo Sphere XMP元数据中描述的元数据才能发布。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?