Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google maps api 3 来自Amazon EC2的地理定位请求_Google Maps Api 3_Google Api_Google Geocoding Api_Google Geolocation - Fatal编程技术网

Google maps api 3 来自Amazon EC2的地理定位请求

Google maps api 3 来自Amazon EC2的地理定位请求,google-maps-api-3,google-api,google-geocoding-api,google-geolocation,Google Maps Api 3,Google Api,Google Geocoding Api,Google Geolocation,我正在部署一个应用程序,它针对谷歌地图地理定位API发出请求。我的请求在我的工作站上顺利通过。但每次从Amazons云中的服务器运行时,我都会收到400个错误请求 下面是我要测试的一个示例curl请求。使用中的API允许任何IP curl -d "{'wifiAccessPoints':[{'macAddress':'c8:d7:19:16:3b:63'},{'macAddress':'c8:d7:19:16:3b:61'}]}" -H "Content-Type: application/js

我正在部署一个应用程序,它针对谷歌地图地理定位API发出请求。我的请求在我的工作站上顺利通过。但每次从Amazons云中的服务器运行时,我都会收到400个错误请求

下面是我要测试的一个示例curl请求。使用中的API允许任何IP

curl -d "{'wifiAccessPoints':[{'macAddress':'c8:d7:19:16:3b:63'},{'macAddress':'c8:d7:19:16:3b:61'}]}" -H "Content-Type: application/json" -i "https://www.googleapis.com/geolocation/v1/geolocate?key=PUTYOURKEYHERE" -v
下面是错误结果的示例

* About to connect() to www.googleapis.com port 443 (#0)
*   Trying 173.194.76.95... connected
* Connected to www.googleapis.com (173.194.76.95) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSL connection using SSL_RSA_WITH_RC4_128_SHA
* Server certificate:
*   subject: CN=*.googleapis.com,O=Google Inc,L=Mountain View,ST=California,C=US
*   start date: Jan 15 14:37:40 2014 GMT
*   expire date: May 15 00:00:00 2014 GMT
*   common name: *.googleapis.com
*   issuer: CN=Google Internet Authority G2,O=Google Inc,C=US
> POST /geolocation/v1/geolocate?key=AIzaSyDzcv8DIbbeGBaONSq2kXh7g9AZbgsiUC8 HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.3.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: www.googleapis.com
> Accept: */*
> Content-Type: application/json
> Content-Length: 93
> 
< HTTP/1.1 400 Bad Request
HTTP/1.1 400 Bad Request
< Content-Type: application/json; charset=UTF-8
Content-Type: application/json; charset=UTF-8
< Date: Thu, 30 Jan 2014 10:56:18 GMT
Date: Thu, 30 Jan 2014 10:56:18 GMT
< Expires: Thu, 30 Jan 2014 10:56:18 GMT
Expires: Thu, 30 Jan 2014 10:56:18 GMT
< Cache-Control: private, max-age=0
Cache-Control: private, max-age=0
< X-Content-Type-Options: nosniff
X-Content-Type-Options: nosniff
< X-Frame-Options: SAMEORIGIN
X-Frame-Options: SAMEORIGIN
< X-XSS-Protection: 1; mode=block
X-XSS-Protection: 1; mode=block
< Server: GSE
Server: GSE
< Alternate-Protocol: 443:quic
Alternate-Protocol: 443:quic
< Transfer-Encoding: chunked
Transfer-Encoding: chunked

< 
{
 "error": {
  "errors": [
   {
    "domain": "geolocation",
    "reason": "invalidRequest",
    "message": "Bad Request"
   }
  ],
  "code": 400,
  "message": "Bad Request"
 }
}
* Connection #0 to host www.googleapis.com left intact
* Closing connection #0
*即将()连接到www.googleapis.com端口443(#0)
*正在尝试173.194.76.95。。。有联系的
*连接到www.googleapis.com(173.194.76.95)端口443(#0)
*使用certpath:sql:/etc/pki/nssdb初始化NSS
*CAfile:/etc/pki/tls/certs/ca-bundle.crt
卡帕斯:没有
*使用SSL\u RSA\u和\u RC4\u 128\u SHA的SSL连接
*服务器证书:
*主题:CN=*.googleapis.com,O=googleinc,L=Mountain View,ST=California,C=US
*开始日期:2014年1月15日14:37:40 GMT
*到期日期:2014年5月15日00:00:00 GMT
*通用名称:*.googleapis.com
*发行人:CN=谷歌互联网管理局G2,O=谷歌公司,C=美国
>POST/geolocation/v1/geolocation?key=AIzaSyDzcv8DIbbeGBaONSq2kXh7g9AZbgsiUC8 HTTP/1.1
>用户代理:curl/7.19.7(x86_64-redhat-linux-gnu)libcurl/7.19.7 NSS/3.14.3.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
>主持人:www.googleapis.com
>接受:*/*
>内容类型:application/json
>内容长度:93
> 
我遇到了完全相同的问题,出于某种原因,相同的
curl
命令可以在ubuntu上运行,但不能在AmazonAMI(centos)上运行。 解决方案是向请求主体添加
considerIp:false
,如下所示:

{
    "considerIp": false,
    "wifiAccessPoints": [
        ...
    ]
}

可能的副本。但您可能需要使用客户端地理编码器。共享服务器共享来自服务器的geocoder请求配额(除非您有业务客户机id的映射)。我使用的是地理位置API,而不是地理编码API。上面的请求在我测试它的任何地方都有效,除了Amazon。你能包括curl
-v
开关并共享EC2实例的curl输出吗?添加详细结果如下requested@steve当我使用verbose开关运行curl时,我确实看到了一个重要的区别,
*上传已完全发送:93个字节中有93个