【问题标题】:Using Google Maps API - sensor true or false REQUEST_DENIED使用 Google Maps API - 传感器 true 或 false REQUEST_DENIED
【发布时间】:2014-03-05 02:36:51
【问题描述】:

我正在尝试以与使用 Firefox 浏览器类似的方式从我的移动应用程序中使用 Maps API:

http://maps.googleapis.com/maps/api/geocode/json?address=First Avenue New York Manhattan&sensor=true

不幸的是,我总是收到这个错误结果:The 'sensor' parameter specified in the request must be set to either 'true' or 'false'

我试过TRUETruetrue...不行。

我还尝试按照本指南使用与我的 google 帐户关联的 API 密钥:https://developers.google.com/maps/documentation/javascript/tutorial?hl=it#api_key

事实上,我做到了:

http://maps.googleapis.com/maps/api/geocode/json?key={my_key}&address=First Avenue New York Manhattan&sensor=true

所以,最后,我想我的问题与我准备的 POST 请求有关。 这是我用于请求的代码:

request = new CIwHTTP; // The http pointer
const char* c1 = text.getCString(); // This is the string "address=First Avenue New York Manhattan&sensor=true"
int length = strlen(c1);
request->SetRequestHeader("Content-Type", "text/javascript; charset=utf-8"); 
request->Post("http://maps.googleapis.com/maps/api/geocode/json", c1, length, callback, NULL);

在回调中我得到了我的结果字符串,希望来自 Google 的 JSON 字符串告诉我地址​​列表。我对 Header 不太确定,但我更改了其中的几个而没有结果。

我使用 Marmalade,所以我的代码完全是 C++。

你能帮帮我吗?

【问题讨论】:

    标签: json api google-maps google-maps-api-3


    【解决方案1】:

    Google 似乎不喜欢地址字符串中的空格,调用应该是 GET 调用。

    这是我的工作代码:

    CCString gURL = "http://maps.googleapis.com/maps/api/geocode/json?"; // URL base 
    CCString *string_final = CCString::createWithFormat( (
            std::string(gURL.getCString()) + 
            std::string(text.getCString()) /* i.e. "address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false" */
            ).c_str() );  
    request->Get(string_final->getCString(),callback, NULL);
    

    【讨论】:

      猜你喜欢
      • 2013-06-26
      • 2010-12-31
      • 2012-05-10
      • 1970-01-01
      • 1970-01-01
      • 2012-02-08
      • 2019-09-18
      • 1970-01-01
      • 2012-02-22
      相关资源
      最近更新 更多