使用Google Geolocation API(ESP8266 NodeMCU)遇到错误403

时间:2019-05-02 05:52:38

标签: arduino-esp8266 google-geolocation

我正在开发一个学校物联网项目。我正在使用Google Geolocation API。该API在过去一个月(直到昨天)运行良好。我现在收到错误403作为响应。 奇怪的是,我大约4小时前醒来,决定再次尝试一下。令我惊讶的是,我的反应是200。快进4小时,API不再起作用。是的,我没有更改代码,因此我的请求似乎格式正确。 这是构建请求的方式:

jsonString="{\n";
jsonString +="\"homeMobileCountryCode\": 234,\n";  // this is a real UK MCC
jsonString +="\"homeMobileNetworkCode\": 27,\n";   // and a real UK MNC
jsonString +="\"radioType\": \"gsm\",\n";          // for gsm
jsonString +="\"carrier\": \"Vodafone\",\n";       // associated with Vodafone 
jsonString +="\"wifiAccessPoints\": [\n";
    for (int j = 0; j < n; ++j)
    {
      jsonString +="{\n";
      jsonString +="\"macAddress\" : \"";    
      jsonString +=(WiFi.BSSIDstr(j));
      jsonString +="\",\n";
      jsonString +="\"signalStrength\": ";     
      jsonString +=WiFi.RSSI(j);
      jsonString +="\n";
      if(j<n-1)
      {
      jsonString +="},\n";
      }
      else
      {
      jsonString +="}\n";  
      }
    }
    jsonString +=("]\n");
    jsonString +=("}\n"); 

这是获取请求的方式:

  Serial.print("Requesting URL: ");


Serial.println("https://" + (String)Host + thisPage + "<API_Key>");
  Serial.println(" ");
  if (client.connect(Host, 443)) {
    Serial.println("Connected");    
    client.println("POST " + thisPage + key + " HTTP/1.1");    
    client.println("Host: "+ (String)Host);
    client.println("Connection: close");
    client.println("Content-Type: application/json");
    client.println("User-Agent: Arduino/1.0");
    client.print("Content-Length: ");
    client.println(jsonString.length());    
    client.println();
    client.print(jsonString);  
    delay(500);
  }

这是返回的响应:

{


"error": {
  "errors": [
   {
    "domain": "usageLimits",
    "reason": "dailyLimitExceeded",
    "message": "This API requires billing to be enabled on the project. Visit https://console.developers.google.com/billing?project=10754516975 to enable billing.",
    "extendedHelp": "https://console.developers.google.com/billing?project=10754516975"
   }
  ],
  "code": 403,
  "message": "This API requires billing to be enabled on the project. Visit https://console.developers.google.com/billing?project=10754516975 to enable billing."
 }
}

地理位置API每天允许1400个请求。我一生中提出了125个请求,那么我如何超出每日限制?

0 个答案:

没有答案