请问下手机端webapi怎样调用,有例子吗,谢谢
- You are here:
- Home
- Q&A
- Q&A
- PowerServer 2020 or older (Obsolete)
- 手机端怎样进行webapi调用
Resolved
手机端怎样进行webapi调用
- How-to
- ? ?
- PowerServer 2020 or older (Obsolete)
- Friday, 8 April 2022 01:08 AM UTC
- Friday, 8 April 2022 01:12 AM UTC
- PowerServer 2020 or older (Obsolete)
- # 1
你好,
请尝试使用httpclient对象调用Web API,比如:
Integer li_rc
String ls_string
HttpClient lnv_HttpClient
lnv_HttpClient = Create HttpClient
// Sends request using GET method
li_rc = lnv_HttpClient.SendRequest("GET", "https://demo.appeon.com/PB/webapi_client/employee/102")
// Obtains the response data
if li_rc = 1 and lnv_HttpClient.GetResponseStatusCode() = 200 then
lnv_HttpClient.GetResponseBody(ls_string)
end if
destroy lnv_HttpClient
messagebox('', ls_string)
Regards,
ZhaoKai
- Friday, 8 April 2022 01:32 AM UTC
- PowerServer 2020 or older (Obsolete)
- # 2
你好,我按你方法可以调用了,但返回的是json, 我手机端怎样解析取到 附件里面标记黄色部分,谢谢
下面是返回的json字符串
{
"status": 0,
"message": "query ok",
"request_id": "d4261cd8-b6d9-11ec-9dc6-246e964f9a82",
"result": {
"location": {
"lat": 28.715725,
"lng": 117.999507
},
"address": "江西省上饶市玉山县S306",
"formatted_addresses": {
"recommend": "玉山县临湖镇岭下村",
"rough": "玉山县临湖镇岭下村"
},
"address_component": {
"nation": "中国",
"province": "江西省",
"city": "上饶市",
"district": "玉山县",
"street": "S306",
"street_number": "S306"
},
"ad_info": {
"nation_code": "156",
"adcode": "361123",
"city_code": "156361100",
"name": "中国,江西省,上饶市,玉山县",
"location": {
"lat": 28.539515,
"lng": 118.343094
},
"nation": "中国",
"province": "江西省",
"city": "上饶市",
"district": "玉山县"
},
"address_reference": {
"street_number": {
"id": "",
"title": "",
"location": {
"lat": 28.801813,
"lng": 117.989334
},
"_distance": 489.2,
"_dir_desc": "东"
},
"town": {
"id": "361123105",
"title": "临湖镇",
"location": {
"lat": 28.729725,
"lng": 117.938759
},
"_distance": 0,
"_dir_desc": "内"
},
"street": {
"id": "15897088507094390441",
"title": "S306",
"location": {
"lat": 28.801813,
"lng": 117.989334
},
"_distance": 489.2,
"_dir_desc": "东"
},
"landmark_l2": {
"id": "3531832548728165799",
"title": "岭下村",
"location": {
"lat": 28.71286,
"lng": 117.996147
},
"_distance": 457.3,
"_dir_desc": "东北"
}
}
}
}
- Kai Zhao @Appeon
- Friday, 8 April 2022 01:51 AM UTC
请使用appeon_workarounds.pbl中提供的eon_cjsonnode和eon_cjsonnodearray对象解析JSON数据,详请参考.
https://docs.appeon.com/ps2020/workarounds_and_api_guide/Accessing_JSON_format_Data.html
Regards,Kai
-
Helpful Loading... Helpful 0
- Friday, 8 April 2022 02:01 AM UTC
- PowerServer 2020 or older (Obsolete)
- # 3
看不懂呀,能提供个例子吗?或者针对上面能指导怎样 写吗?谢谢
- Kai Zhao @Appeon
- Friday, 8 April 2022 02:04 AM UTC
-
Helpful Loading... Helpful 0
- Monday, 11 April 2022 00:04 AM UTC
- PowerServer 2020 or older (Obsolete)
- # 4
服务名:
NEZ.AutoTally.ApiService.Base.QueryConfirmResultService
请求参数
{
"StartTime":"2021-07-12 00:00:00", --起始确认时间
"EndTime":"2021-07-12 23:59:00", --截止确认时间
"Vessel":"", --船中文名
"Voyage":"" --航次
}
请求参数限制:
1.起始确认时间、截止确认时间
2.时间间隔大于1天时,船中文名、航次必输
你好,上面这样的怎样调用呀?谢谢
- Monday, 11 April 2022 02:35 AM UTC
- PowerServer 2020 or older (Obsolete)
- # 5
服务器地址:http://192.168.99.199:8080/api/exchange
Headers中增加两个节点
Key:ClientID,Value:JJZNLH
Key:ServiceName,Value各接口文档中服务名
服务名:
NEZ.AutoTally.ApiService.Base.QueryConfirmResultService
请求参数
{
"StartTime":"2021-07-12 00:00:00", --起始确认时间
"EndTime":"2021-07-12 23:59:00", --截止确认时间
"Vessel":"", --船中文名
"Voyage":"" --航次
}
请求参数限制:
1.起始确认时间、截止确认时间
2.时间间隔大于1天时,船中文名、航次必输
请问下,这样带key 的怎样调用呀?我按下面写 不行,不知道怎样加key ,谢谢
Integer li_rc
String ls_ReturnJson
HttpClient lnv_HttpClient
lnv_HttpClient = Create HttpClient
string srq1,srq2,scm,shc
srq1="2021-08-02 00:00:00"
srq2="2021-08-02 23:59:00"
String ls_json
ls_json= '{"StartTime":"'+srq1+'","EndTime":"'+srq2+'","Vessel":"'+scm+'","Voyage":"'+shc+'"}'
messagebox("",ls_json)
// Constructs a POST request (supports all headers)
lnv_HttpClient.SetRequestHeader("Content-Type", "application/json;charset=UTF-8")
// Content-Length header set by SendRequest
// Sends request using POST method (to add the string data to the body and set to the Content-Length header)
li_rc = lnv_HttpClient.SendRequest("POST","http://192.168.99.199:8080/api/exchange", ls_json)
// Obtains the response data
if li_rc = 1 and lnv_HttpClient.GetResponseStatusCode() = 200 then
lnv_HttpClient.GetResponseBody(ls_ReturnJson)
messagebox("","ok")
messagebox("",ls_ReturnJson)
else
messagebox("","no")
end if
- Kai Zhao @Appeon
- Monday, 11 April 2022 05:04 AM UTC
-
Helpful Loading... Helpful 0
- Page :
- 1
However, you are not allowed to reply to this question.