Home > Backend Development > PHP Tutorial > php-微信PHP服务器端调用图灵机器人接口失败

php-微信PHP服务器端调用图灵机器人接口失败

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-02 11:32:40
Original
1230 people have browsed it

接口php图灵机器人

采用官方提供的demo但是没有成功,求大神指点啊!

protected function talk($content){
$key = 'xxxxxxx'; //这里填写你的apikey
$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;

<code>    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;</code>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template