Jquery 使用esv圣经web服务
我将在我的个人网站上使用公共web服务 我已经拿到API密钥了。对于一般测试,“IP”可以是关键。它有一个asp代码Jquery 使用esv圣经web服务,jquery,json,wcf,asp.net-mvc-4,wcf-rest,Jquery,Json,Wcf,Asp.net Mvc 4,Wcf Rest,我将在我的个人网站上使用公共web服务 我已经拿到API密钥了。对于一般测试,“IP”可以是关键。它有一个asp代码 <% 'Reference Search key = "IP" strSearch = "John 1" passage = Server.URLEncode(strSearch) options = "include-passage-references=true" set objHTTP = Server.CreateObject("Microso
<%
'Reference Search
key = "IP"
strSearch = "John 1"
passage = Server.URLEncode(strSearch)
options = "include-passage-references=true"
set objHTTP = Server.CreateObject("Microsoft.XMLHTTP")
objHTTP.open "GET", "www.esvapi.org/v2/rest/passageQuery?key=" & _
key & "&passage=" & passage & "&" & options, false
objHTTP.send
Response.Write(objHTTP.responseText)
%>
您可以从System.Net命名空间使用WebClient进行此操作
var client = new WebClient();
var query = string.Format("www.esvapi.org/v2/rest/passageQuery?key={0}&passage={1}&options={2}", "IP", Server.UrlEncode(strSearch),options);
var result = client.DownloadString(query);
我还没有把它放到IDE中,所以你可能需要检查一下我必须把这些代码放到Razor中,添加@?然后以字符串形式返回响应?在控制器中,您可以选择显示方式,例如从操作返回contentresult并使用ajax使用它,或者将其作为视图的模型传递并在其中显示。