名称 | 类型 | 必填 | 默认值 | 说明 |
---|---|---|---|---|
keyword | string | 是 | 关键词 |
名称 | 类型 | 默认值 | 说明 |
---|---|---|---|
errcode | string | 0 | 返回的错误代码 |
errmsg | string | 返回的错误说明 | |
hashkey | string | 提交成功后会返回唯一key值 | |
progress | int | 当前任务进度 |
{ "errcode": "0", "errmsg": "", "data": { "hashkey": "BF394B4E452C48DXXXX802B097A0802A", "progress": 90, "result": [] } }
名称 | 类型 | 必填 | 默认值 | 说明 |
---|---|---|---|---|
hashkey | string | 是 | 报告key值 |
名称 | 类型 | 默认值 | 说明 |
---|---|---|---|
errcode | string | 0 | 返回的错误代码 |
errmsg | string | 返回的错误说明 | |
nodeid | int | 节点ID | |
parent_nodeid | int | 父节点ID | |
name | string | 射频词 | |
data_count | int | 出现次数 |
{ "errcode": "0", "errmsg": "", "data": { "hashkey": "BF394B4E452C48DXXXX802B097A0802A", "progress": 100, "result": [ { "nodeid": 94984673, "name": "华为鸿蒙系统", "parent_nodeid": 0, "data_count": 0 }, { "nodeid": 94984674, "name": "华为手机", "parent_nodeid": 94984673, "data_count": 194 }, { "nodeid": 94984675, "name": "手机系统", "parent_nodeid": 94984674, "data_count": 27 }, ... ] }
错误码 | 说明 |
---|---|
100101 | 调用次数不够,请充值 |
100102 | 服务每秒调用量超限 |
100103 | 服务每小时调用量超限 |
100104 | 服务每天调用量超限 |
100111 | 调用字数不够,请充值 |
100201 | url无法解析 |
100202 | 请求缺少apikey |
100203 | 无效的apikey |
100204 | api不存在 |
100205 | api已经关闭 |
100206 | 后端服务响应status非200 |
100207 | 后端服务未正确接入 |
100208 | 请求方式不支持 |
100301 | Api商城 内部错误 |
100302 | 请求后端服务过程中错误 |
100303 | 系统繁忙稍候再试 |
100403 | 您输入的apikey不正确 |
错误码 | 说明 |
---|---|
200104 | 数据获取中 |
200107 | 服务器超时 |
200201 | 传进参数为空 |
200202 | 用户ID为空 |
200409 | 输入非法字符 |
2 | 002 | 01 |
---|---|---|
服务器错误(1:为系统级别错误) | 服务模块代码(即数据ID) | 具体错误代码 |
名称 | 价格 | 次数 | 说明 |
---|---|---|---|
首次试用套餐 | 0.00 | 100 | |
套餐一 | 300.00 | 10000 | |
套餐二 | 1800.00 | 100000 | |
套餐三 | 9000.00 | 1000000 |
<?php
header("Content-type:text/html; charset=utf-8");
/*参数1:请求的URL;参数2:以CURL方式设置http的请求头;参数3:要提交的数据包*/
function doCurlPostRequest($url,$header,$data){
$ch = curl_init();
/*请求地址*/
curl_setopt($ch, CURLOPT_URL, $url);
/*以CURL方式设置http的请求头*/
curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
/*文件流形式*/
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
/*发送一个常规的Post请求*/
curl_setopt($ch, CURLOPT_POST, 1);
/*Post提交的数据包*/
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
return curl_exec($ch);
}
/*请求的URL*/
$url = "http://apis.5118.com/naotu/radiate";
/*要提交的数据包*/
$data = "keyword=放射;
/*以CURL方式设置http的请求头*/
$header[] = "Content-type:application/x-www-form-urlencoded";
/*输入你要调用API的APIKEY*/
$header[] = "Authorization: APIKEY XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
/*调用CURL POST函数*/
$result=doCurlPostRequest($url,$header,$data);
/*对 JSON 格式的字符串进行解码,并转换为 PHP 变量*/
$json = json_decode($result);
/*errcode=0 正确返回 errcode=200104 数据分析中*/
$errcode = $json->errcode;
$errmsg = $json->errmsg;
if ($errcode != "0" && $errmsg != "") {
/*非正确返回*/
print_r($result);
exit;
}
/*提交成功后返回唯一key值*/
$hashkey = $json->data->hashkey;
if ($hashkey != "") {
/*要提交的数据包*/
$data = "hashkey=".$hashkey;
/*调用CURL POST函数*/
$result = doCurlPostRequest($url,$header,$data);
$json = json_decode($result);
$errcode = $json->errcode;
$errmsg = $json->errmsg;
/*errcode=200104 数据分析中*/
if ($errcode == "200104" && $errmsg =="数据分析中") {
while(true){
sleep(5);
/*调用CURL POST函数*/
$result = doCurlPostRequest($url,$header,$data);
$errcode = $json->errcode;
$errmsg = $json->errmsg;
/*errcode=0 正确返回*/
if ($errcode == "0" && $errmsg == "") {
print_r($result);
/*退出当前的脚本*/
exit;
}
}
}
else {
/*返回数据结果*/
print_r($result);
}
}
else {
/*返回异常或其它信息*/
print_r($result);
}
/*退出当前的脚本*/
exit;
?>
using System.IO;
using System.Text;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
private const String host = "http://apis.5118.com";
private const String path = "/naotu/radiate";
private const String method = "POST";
private const String apikey = "你要调用的接口apikey";
static void Main(string[] args)
{
String querys = "";
String bodys = "keyword=keyword";
String url = host + path;
HttpWebRequest httpRequest = null;
HttpWebResponse httpResponse = null;
if (0 < querys.Length)
{
url = url + "?" + querys;
}
if (host.Contains("https://"))
{
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
httpRequest = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url));
}
else
{
httpRequest = (HttpWebRequest)WebRequest.Create(url);
}
httpRequest.Method = method;
httpRequest.Headers.Add("Authorization", apikey);
//根据API的要求,定义相对应的Content-Type
httpRequest.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
if (0 < bodys.Length)
{
byte[] data = Encoding.UTF8.GetBytes(bodys);
using (Stream stream = httpRequest.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
}
try
{
httpResponse = (HttpWebResponse)httpRequest.GetResponse();
}
catch (WebException ex)
{
httpResponse = (HttpWebResponse)ex.Response;
}
Console.WriteLine(httpResponse.StatusCode);
Console.WriteLine(httpResponse.Method);
Console.WriteLine(httpResponse.Headers);
Stream st = httpResponse.GetResponseStream();
StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8"));
Console.WriteLine(reader.ReadToEnd());
Console.WriteLine("\n");
}
public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
return true;
}