Home > php教程 > PHP源码 > 百小度机器人聊天接口

百小度机器人聊天接口

PHP中文网
Release: 2016-05-20 12:58:08
Original
2787 people have browsed it

php代码

<?php
$msg=urlencode(&#39;你几岁了?&#39;);//内容

$url = "https://sp0.baidu.com/yLsHczq6KgQFm2e88IuM_a/s?sample_name=bear_brain&request_query=&#39;.$msg.&#39;&bear_type=1";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIE, &#39;BDUSS=你的bduss&#39;);
$content = curl_exec($ch);
curl_close($ch);
$content=json_decode($content);
//print_r($content);

$content=$content->result_list[0]->result_content;
//print_r($content);
$content=json_decode($content);
//print_r($content);
$content=$content=$content->answer;
$content=str_replace("小度","滑小稽",$content);
$content=str_replace("<AGE>","21",$content);
echo $content;
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
Latest Articles by Author
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template