诺基亚HERE Api->;缺少身份验证参数


NokiaHERE Api -> Missing authentication parameters

我想用诺基亚Here地图获取城市中某个地方的一些数据。因此,我想执行一个cuRL请求。我正在构建这样的cURL请求:

$postFields                 = array ( "app_id" => self::APP_ID, "app_code" => self::APP_CODE, "at" => $latLon['lat'] . "," .$latLon['lon'], "q" => $term, "pretty" => "true");
$this->_curl->setUrl        ( $this->getUrl() );
$this->_curl->setPostField  ( $postFields );
$curlResults                = $this->_curl->execute();
var_dump ( $curlResults );

但当我在浏览器中这样做时,我会得到

"{"status":401,"message":"Missing authentication parameters"}"

然而,当我打印出全部内容时。类似于使用构建查询

echo $this->getUrl() . "?app_id=" . self::APP_ID, "&app_code=" . self::APP_CODE . "&at=" . $latLon['lat'] . "," .$latLon['lon'] . "&q=" . $term . "&pretty=" . "true";

它工作起来没有任何问题。为什么诺基亚告诉我缺少身份验证参数?

这是查询字符串

http://places.nlp.nokia.com/places/v1/discover/search?app_id=XXXXXXX&app_code=XXXXXXX&at=51.2151915838703%2C6.76354323416523&q=Rewe&pretty=true

由于您还没有提供自己测试的方法,我认为他们不支持$_POST,这就是您正在做的。

尝试以下操作:

$postFields                 = array ( "app_id" => self::APP_ID, "app_code" => self::APP_CODE, "at" => $latLon['lat'] . "," .$latLon['lon'], "q" => $term, "pretty" => "true");
$this->_curl->setUrl        ( $this->getUrl() . '?' . http_build_query( $postFields ) );
//$this->_curl->setPostField  ( $postFields );
$curlResults                = $this->_curl->execute();
var_dump ( $curlResults );

这将执行一个GET请求,该请求有效(根据您的说法(。

由于缺少上下文(您是如何设置self::APP_ID和self::APP_CODE的?(以及缺乏PHP知识,我无法解决您的问题。

但是,错误消息"Missing authentication params"指示curl生成的请求缺少app_id或app_code参数或两者,而不是错误的app_id(在当前实现中(会给出错误消息"Invalid app_id app_code combination",这可能有助于搜索。

示例:

http://places.nlp.nokia.com/places/v1/discover/search?app_code=xxxxxxx&在=51.2151915838703%2C6.76354323416523&q=回放&漂亮=真正的

返回401,消息为"缺少身份验证参数",而

http://places.nlp.nokia.com/places/v1/discover/search?app_id=xxxxxx&app_code=xxxxxxx&在=51.2151915838703%2C6.76354323416523&q=回放&漂亮=真正的

返回一个401,消息为"无效的app_id app_code组合"。

我"解决"了它,只需请求一个新的应用程序Id和应用程序代码。不知道为什么以前的不起作用,但现在我没有任何大问题。对于任何好奇的人。我的请求现在看起来是这样的(我试图让它尽可能简单(

$getString = $this->getUrl() . $this->getAuthString() . "&at=" . $where['lat'] . "," . $where['lon'] . "&q=" . $term . "&pretty=true&size=100";