關於一言可以自行百度點擊看一言首頁
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>API調用</title>
</head>
<h1>一言API實例<h1>
<br />
<?php
//$testurl = "https://v1.hitokoto.cn/?參數(見上面,詳見一言官網)"
//因爲方便,使用要用text編碼請求
$testurl = "https://v1.hitokoto.cn/?C=b&encode=text&charset=utf-8";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $testurl);
//參數爲1表示傳輸數據,爲0表示直接輸出顯示。
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//參數爲0表示不帶頭文件,爲1表示帶頭文件
curl_setopt($ch, CURLOPT_HEADER,0);
$output = curl_exec($ch);
curl_close($ch);
echo $output;
return $output;
?>
<body>
</body>
</html>