Developer.here.com API可根据要求挂起

时间:2016-08-10 09:41:37

标签: javascript json api

我只是寻找一个webservice,它返回给定地图和起点的旅行时间的等时线,并找到这个代码示例似乎做了我想要的:

https://developer.here.com/rest-apis/documentation/routing/topics/example-isoline-simple-time.html

但是我不知道如何使用它。我用Google搜索,但没有找到任何帮助。我从https://developer.here.com/创建了一个免费计划,以获取app_id和app_code。我只是使用它们从下面的示例代码创建一个单行字符串并将其复制到我的浏览器的url行,但它没有显示任何它只是说它正在等待服务器。

https://isoline.route.cit.api.here.com/routing/7.2/calculateisoline.json
?app_id={YOUR_APP_ID}
&app_code={YOUR_APP_CODE}
&mode=fastest;car;traffic:disabled
&rangetype=time
&start=geo!52.51578,13.37749
&range=300

那么使这个例子工作的正确方法是什么(如果这很重要,可以从linux获得)。

修改

以下是我的测试应用的app_id和app_code:

Test_Data

然后我将以下字符串复制到我的url-bar:

https://isoline.route.cit.api.here.com/routing/7.2/calculateisoline.json?app_id={dvCtO8JoOhmzZGqOaNve}&app_code={N4p8QokLC5D1xYf_rk3z5g}&mode=fastest;car;traffic:disabled&rangetype=time&start=geo!52.51578,13.37749&range=300

这有什么不对吗?

修改2

在firefox中,这只是挂起,并在几分钟后给出“安全连接失败”错误。我也尝试使用chrome-browser,导致以下错误消息:

{"response":{"_type":"ns2:RoutingServiceErrorType","type":"PermissionError","subtype":"InvalidCredentials","details":"This is not a valid app_id and app_code pair. Please verify that the values are not swapped between the app_id and app_code and the values provisioned by HERE (either by your customer representative or via http://developer.here.com/myapps) were copied correctly into the request.","metaInfo":{"timestamp":"2016-08-10T11:03:37Z","mapVersion":"8.30.62.159","moduleVersion":"7.2.71.0-39010","interfaceVersion":"2.6.25"}}}

1 个答案:

答案 0 :(得分:1)

但是没有工作错误405(预检的响应有无效的HTTP状态代码405),而且是真的...我不知道auth你的web api。看一下示例代码就是尝试。

示例代码



$(document).ready(function() {
	var app_id = "dvCtO8JoOhmzZGqOaNve";
	var app_code = "N4p8QokLC5D1xYf_rk3z5g";
	$.ajax({
		url: "https://isoline.route.cit.api.here.com/routing/7.2/calculateisoline.json", 
		type: "GET",
		dataType: "jsonp",
		beforeSend: function(xhr) { 
		  xhr.setRequestHeader("Authorization", "Basic "+btoa(app_id+":"+app_code)); 
		},
		data: [{
			"mode":"fastest;car;traffic:disabled",
			"rangetype":"time",
			"start":"geo!52.51578,13.37749",
			"range":"300"
		}]
		/*
        mode:"fastest;car;traffic:disabled",
		rangetype:"time",
		start:"geo!52.51578,13.37749",
		range:"300"/*,
		success: function(data) {
			console.log(data);
		}*/
	}, function (data) { console.log(data); });
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
&#13;
&#13;
&#13;

相关问题