【问题标题】:Here Maps "These credentials do not authorize access"此处映射“这些凭据不授权访问”
【发布时间】:2021-01-27 06:23:06
【问题描述】:

我正在尝试从 here.com API 获取数据,但它不断返回 401 错误。

{"error":"Unauthorized","error_description":"These credentials do not authorize access"}

代码

$minutes = 60;
$forecast = Cache::remember('forecast', $minutes, function () {
    $app_id = env('HERE_APP_ID');
    $app_code = env('HERE_APP_CODE');
    $lat = env('HERE_LAT_DEFAULT');
    $lng = env('HERE_LNG_DEFAULT');
    $url = "https://weather.api.here.com/weather/1.0/report.json?product=forecast_hourly&latitude=${lat}&longitude=${lng}&oneobservation=true&language=in&app_id=${app_id}&app_code=${app_code}";

    Log::info($url);


    $client = new \GuzzleHttp\Client();
    $res = $client->get($url);
    if ($res->getStatusCode() == 200) {
        $j = $res->getBody();
        $obj = json_decode($j);
        $forecast = $obj->hourlyForecasts->forecastLocation;
    }
    return $forecast;
});

有什么想法吗?

【问题讨论】:

  • 试试这个网址$url = "https://weather.api.here.com/weather/1.0/report.json?product=forecast_hourly&latitude=$lat&longitude=$lng&oneobservation=true&language=in&app_id=$app_id&app_code=$app_code";
  • @KamleshPaul 同样的错误
  • 然后转到weather api仪表板并启用该服务
  • 是否有单独的天气仪表板?

标签: php laravel authentication here-api


【解决方案1】:

API 密钥 一起使用的正确 API 端点不是https://weather.api.here.com,而是https://weather.ls.hereapi.com/

例如:

 https://weather.ls.hereapi.com/weather/1.0/report.json?apiKey=YOUR-API-KEY&product=alerts&name=Paris

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-10-05
    • 1970-01-01
    • 2022-10-13
    • 1970-01-01
    • 2022-11-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多