<?php
header("Content-Type: text/html; charset=utf-8");
$data = file_get_contents ('https://www.88qun.cn/robotIfController.ehtm?ehtm_page=/module/setting/robotIfdp
?appkey=APIKEY&threadId=会话id&userId=用户id&robotHashCode=机器人id&platformConnType=渠道编号&receiverId=版本编号
&sendTime=提问时间&content=问题内容&process=0');//API接口
$json = json_decode($data,true);//将json解析成数组
if($json['code'] == 200){ //判断状态码
print_r($json); //打印数组
}else{
echo "返回错误,状态消息:".$json['msg'];
}
?>
# -*- coding: utf-8 -*-
import sys, urllib, urllib2, json
url = 'https://www.88qun.cn/robotIfController.ehtm?ehtm_page=/module/setting/robotIfdp
?appkey=APIKEY&threadId=会话id&userId=用户id&robotHashCode=机器人id&platformConnType=渠道编号&receiverId=版本编号
&sendTime=提问时间&content=问题内容&process=0'
req = urllib2.Request(url)
resp = urllib2.urlopen(req)
content = resp.read()
if(content):
print(content)
String httpUrl = "https://www.88qun.cn/robotIfController.ehtm?ehtm_page=/module/setting/robotIfdp
?appkey=APIKEY&threadId=会话id&userId=用户id&robotHashCode=机器人id&platformConnType=渠道编号&receiverId=版本编号
&sendTime=提问时间&content=问题内容&process=0";
String jsonResult = request(httpUrl);
System.out.println(jsonResult);
/**
* @param urlAll
* :请求接口
* @param httpArg
* :参数
* @return 返回结果
*/
public static String request(String httpUrl, String httpArg) {
BufferedReader reader = null;
String result = null;
StringBuffer sbf = new StringBuffer();
httpUrl = httpUrl + "?" + httpArg;
try {
URL url = new URL(httpUrl);
HttpURLConnection connection = (HttpURLConnection) url
.openConnection();
connection.setRequestMethod("GET");
InputStream is = connection.getInputStream();
reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
String strRead = null;
while ((strRead = reader.readLine()) != null) {
sbf.append(strRead);
sbf.append("\r\n");
}
reader.close();
result = sbf.toString();
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
//页面需引入jquery库
$(document).ready(function(){
$("button").click(function(){
$.get("https://www.88qun.cn/robotIfController.ehtm?ehtm_page=/module/setting/robotIfdp
?appkey=APIKEY&threadId=会话id&userId=用户id&robotHashCode=机器人id&platformConnType=渠道编号&receiverId=版本编号
&sendTime=提问时间&content=问题内容&process=0",
function(data,status){
console.log(data);
$('#result').append(JSON.stringify(data)); //返回内容绑定到ID为result的标签
alert("状态码:" + data.code + "\n消息:" + data.msg);
});
});
});