最近做一个接口调用
对方接口只有
HTTP的
接口说明
EXLIVE开放平台增加动态数据接口,主要以JSON格式返回车辆当前位置数据、轨迹回放数据等等车辆动态信息
(1)信息内容为json格式,必须采用UTF-8编码。(建议提交方式为post方法,可以避免汉字乱码问题)
HT请求TP例子:
http://60.195.248.67:89/gpsonline/GPSAPI?version=1&method=loginSystem&name=sunyan&pwd=123456
返回格式:
{
"version":1,
"success":true,
"uid":2103811,
"uKey":"4cb75a5b8ea89966691535021db029fb"
}
我目前用的POSTURL 来写的
但是不知道怎么获取返回的 JSON格式的值
目前写的代码
Blob lblb_args
String ls_header
String ls_url
String ls_args
long ll_length
integer li_rc
li_rc = GetContextService( "Internet", iinet_base )
IF li_rc = 1 THEN
iinet = Create n_iinet
ir = CREATE n_ir_msgbox
ls_url = "http://125.64.14.211:89/gpsonline/GPSAPI?"
ls_args = "version=1&method=loginSystem&name=hds&pwd=666888"
lblb_args = Blob( ls_args )
ll_length = Len( lblb_args )
ls_header = "Content-Type: " + &
"application/x-www-form-urlencoded~n" + &
"Content-Length: " + String( ll_length ) + "~n~n"
li_rc = iinet.PostURL( ls_url, lblb_args, ls_header, ir )
END IF
提交的状态li_rc 好获取,但是提交的JSON格式返回值呢
------解决思路----------------------
下面是一则获取新浪Stock接口例子,希望对你有所帮助
//====================================================================
// 函数: nvo_stock.constructor()
//--------------------------------------------------------------------
// 描述: 初始化
//--------------------------------------------------------------------
// 参数:
//--------------------------------------------------------------------
// 返回: long
//--------------------------------------------------------------------
//====================================================================
String ls_xmlhttp[]
integer li_flag
ls_xmlhttp[1] = "Msxml2.XMLHTTP.6.0"
ls_xmlhttp[2] = "Msxml2.XMLHTTP.5.0"
ls_xmlhttp[3] = "Msxml2.XMLHTTP.4.0"
ls_xmlhttp[4] = "Msxml2.XMLHTTP.3.0"
ls_xmlhttp[5] = "Msxml2.XMLHTTP"
ioo_xmlhttp = Create oleobject
For li_flag = 1 To UpperBound( ls_xmlhttp)
If ioo_xmlhttp.ConnectToNewObject(ls_xmlhttp[li_flag]) = 0 Then
ib_Flag = True
Exit
End If
Next
//====================================================================
// 事件: nvo_stock.uf_getvalue()
//--------------------------------------------------------------------
// 描述: 获取数据
//--------------------------------------------------------------------
// 参数:
// value string as_stockcode
// reference string as_stockvalue
//--------------------------------------------------------------------
// 返回: boolean
//--------------------------------------------------------------------
//====================================================================
String ls_status_text
Long ll_status_code
ioo_xmlhttp.Open("GET","http://hq.sinajs.cn/list=" + as_stockcode, False)
ioo_xmlhttp.Send()
//Get our response
ls_status_text = ioo_xmlhttp.StatusText
ll_status_code = ioo_xmlhttp.Status
//Check HTTP Response code for errors
If ll_status_code >= 300 Then
Return False
End If
//Get the response we received from the web server
as_stockvalue = ioo_xmlhttp.ResponseText
Return True