Interface php Turing robot
Use the official demo but did not succeed, ask the great God pointing Ah!
protected function Talk ($content) {
$key = ' xxxxxxx '; Fill in your apikey here
$re = Json_decode (file_get_contents (' http://www.tuling123.com/openapi/api?key= '. $key. ' &info= '. $content), true);
$code = $re [' Code '];
Switch ($code) {
Case 100000:
$content = $re [' text '];
Break
case 305000: $list = $re['list']; $i = rand(0,count($list)-1); $list = $list[$i]; $content = '起始站:'.$list['start'].',到达站:'.$list['terminal'].',开车时间:'.$list['starttime'].',到达时间:'.$list['endtime'].'。亲,更多信息请上网查询哦!'; break; case 306000: $list = $re['list']; $i = rand(0,count($list)-1); $list = $list[$i]; $content = '航班:'.$list['flight'].',航班路线:'.$list['route'].',起飞时间:'.$list['starttime'].',到达时间:'.$list['endtime'].'。亲,更多信息请上网查询哦!'; break; case 40004: $content = '今天累了,明天再聊吧'; break; default: $content = $re['text'];}return $content;