当前位置:   article > 正文

智能问答机器人php,智能问答API接口_免费数据接口 - 极速数据

php 关键词问答机器人

require_once 'curl.func.php';

$appkey = 'your_appkey_here';//你的appkey

$question = '杭州天气';//问题(utf8)

$url = "https://api.jisuapi.com/iqa/query?appkey=$appkey&question=$question";

$result = curlOpen($url, ['ssl'=>true]);

$jsonarr = json_decode($result, true);

//var_dump($jsonarr);

if($jsonarr['status'] != 0)

{

echo $jsonarr['msg'];

exit();

}

$result = $jsonarr['result'];

echo $result['type'].' '.$result['content'] . '

';

foreach($result['relquestion'] as $val)

{

echo $val.'

';

}

#!/usr/bin/python

# encoding:utf-8

import urllib2, json, urllib

# 1、智能回复

data = {}

data["appkey"] = "your_appkey_here"

data["question"] = "杭州天气"

url_values = urllib.urlencode(data)

url = "https://api.jisuapi.com/iqa/query" + "?" + url_values

request = urllib2.Request(url)

result = urllib2.urlopen(request)

jsonarr = json.loads(result.read())

if jsonarr["status"] != u"0":

print jsonarr["msg"]

exit()

result = jsonarr["result"]

print result["type"],result["content"]

for row in result["relquestion"]:

print row

package api.jisuapi.iqa;

import java.net.URLEncoder;

import api.util.HttpUtil;

import net.sf.json.JSONObject;

public class Query {

public static final String APPKEY = "your_appkey_here";// 你的appkey

public static final String URL = "https://api.jisuapi.com/iqa/query";

public static final String question = "杭州天气";// 问题(utf-8)

public static void Get() throws Exception {

String result = null;

String url = URL + "?appkey=" + APPKEY + "&question=" + URLEncoder.encode(question, "utf-8");

try {

result = HttpUtil.sendGet(url, "utf-8");

JSONObject json = JSONObject.fromObject(result);

if (json.getInt("status") != 0) {

System.out.println(json.getString("msg"));

} else {

JSONObject resultarr = json.optJSONObject("result");

String type = resultarr.getString("type");

String content = resultarr.getString("content");

String relquestion = resultarr.getString("relquestion");

System.out.println(type + " " + content + " " + relquestion);

}

} catch (Exception e) {

e.printStackTrace();

}

}

}

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/正经夜光杯/article/detail/854835
推荐阅读
相关标签
  

闽ICP备14008679号