Created
September 17, 2017 07:07
-
-
Save sunnoy/91fa516daea4c0f61e58a5835e72e6b6 to your computer and use it in GitHub Desktop.
medium
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case 'text': | |
$urlcon = $message->Content; | |
// //发送到图灵机器人接口 | |
// | |
// $url = "http://www.tuling123.com/openapi/api?key=f7b6e44c70ea46f3972d95e7bd044789&info=" . $content; | |
// //获取图灵机器人返回的内容 | |
// $content = file_get_contents($url); | |
// //对内容json解码 | |
// $content = json_decode($content); | |
// //把内容发给用户 | |
$client = new Client(); //GuzzleHttp\Client | |
$result = $client->request('POST', 'http://www.tuling123.com/openapi/api', [ | |
'form_params' => [ | |
'key' => 'f7b6e44c70ea46f3972d95e7bd044789', | |
'info' => $urlcon, | |
'userid' => $message->FromUserName, | |
] | |
]); | |
$content = $result->getBody()->getContents(); | |
$content = json_decode($content); | |
$text = $content->text; | |
if (!empty($content->url)) { | |
$urll = $content->url; | |
}; | |
if (!empty($content->list)) { | |
$list = $content->list; | |
} | |
$tuling = $text; | |
if (!empty($urll)) { | |
$tuling = $text . $urll; | |
} elseif (!empty($list)) { | |
$tuling = $text . $list; | |
} elseif (!empty($urll) && !empty($list)) { | |
$tuling = $text . $urll . $list; | |
} | |
return new Text(['content' => $tuling]); | |
break; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment