如果你下載下來了,你一定要善待這隻雞。下載下來開啟就可以聊天!我放到了我的伺服器上,國慶日我無聊就找雞。
http://www.wbaobao.top/talkJJ/
程式碼核心就是呼叫介面跟前台的輸出js的使用方法。
它可能沒有你想像的那麼黃,最黃的在韓國。 <?php <br />
namespace HomeController;<br>
use ThinkController;<br>
class IndexController extends Controller {<br>
public function index(){<br>
$this->display();<br>
}<br>
public function data(){<br>
if (IS_POST) {<br>
$appkey = "5e70fea5553d2deea473c13b516a564a";<br>
$url = "http://op.juhe.cn/robot/index";<br>
$metock=I("post.txt","haha");<br>
$params = array(<br>
"key" => $appkey,//您所申請的本介面專用的APPKEY<br>
"info" => $metock,//要傳送給機器人的內容,且不要超過30個字<br>
"dtype" => "",//返回的資料的格式,json或xml,預設為json<br>
"loc" => "",//地點,如北中關村<br>
"lon" => "",//經度,東經116.234632(小數點後保留66234632<br>
"lat" => "",//緯度,北緯40.234632(小數點後保留6位元),且需寫上6位元
"userid" => "",//1~32位,此userid針對您自己的每一個用戶,用於情境的關聯<br>
);<br>
$params=http_build_query($params);<br>
$ispost=0;<br>
$httpInfo = array();<br>
$ch = curl_init();<br>
curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 );<br>
curl_setopt( $ch, CURLOPT_USERAGENT , 'JuheData' );<br>
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 60 );<br>
curl_setopt( $ch, CURLOPT_TIMEOUT , 60);<br>
curl_setopt( $ch, CURLOPT_RETURNTRANSFER , true );<br>
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);<br>
curl_setopt( $ch , CURLOPT_URL , $url.'?'.$params );<br>
$response = curl_exec( $ch );<br>
if ($response === FALSE) {<br>
return false;<br>
}<br>
$httpCode = curl_getinfo( $ch , CURLINFO_HTTP_CODE );<br> $httpInfo = array_merge($httpInfo , curl_getinfo($ch ) );<br>
curl_close($ch);<br>
$data=json_decode($response,ture)["結果"]["文字"];<br>
$返回=[<br>
「文字」=>$數據,<br>
];<br>
$this->ajaxReturn($return);<br>
}<br>
}<br>
}
談話JJ.rar ( 1.25 MB 下載:63次 )