<?php
require_once 'curl.func.php';
$appkey = 'your_appkey_here';//你的appkey
$word = '好像';//utf8
$url = "https://api.jisuapi.com/cidian/word?appkey=$appkey&word=$word";
$result = curlOpen($url, ['ssl'=>true]);
$jsonarr = json_decode($result, true);
//exit(var_dump($jsonarr));
if($jsonarr['status'] != 0)
{
echo $jsonarr['msg'];
exit();
}
$result = $jsonarr['result'];
echo $result['name'].' '.$result['pinyin'].' '.$result['content'].' '.$result['example'].' '.$result['comefrom'].' '.implode(',', $result['jin']).' '.implode(',', $result['fan']).'
';
#!/usr/bin/python
# encoding:utf-8
import urllib2, json, urllib
# 1、汉语词典查询
data = {}
data["appkey"] = "your_appkey_here"
data["word"] = "好像"
url_values = urllib.urlencode(data)
url = "https://api.jisuapi.com/cidian/word" + "?" + 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["name"],result["pinyin"],result["content"],result["example"],result["comefrom"],",".join( result["jin"]),",".join(result["fan"])
package api.jisuapi.cidian;
import java.net.URLEncoder;
import api.util.HttpUtil;
import net.sf.json.JSONObject;
public class Word {
public static final String APPKEY = "your_appkey_here";// 你的appkey
public static final String URL = "https://api.jisuapi.com/cidian/word";
public static final String word = "好像";// utf-8
public static void Get() throws Exception {
String result = null;
String url = URL + "?appkey=" + APPKEY + "&word=" + URLEncoder.encode(word,"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 name = resultarr.getString("name");
String pinyin = resultarr.getString("pinyin");
String content = resultarr.getString("content");
String example = resultarr.getString("example");
String comefrom = resultarr.getString("comefrom");
String jin = resultarr.getString("jin");
String fan = resultarr.getString("fan");
System.out.println(
name + " " + pinyin + " " + content + " " + example + " " + comefrom + " " + jin + " " + fan);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}