### 请求参数
| 参数名称 | 类型 | 必须 | 描述 |
| --- | --- | --- | --- |
| title | String | 否 | 新闻主标题 |
| newstype_id | Number| 否 | 新闻类型id,根据新闻类型检索新闻 |
### 返回`data`参数
| 名称 | 类型 | 说明 |
| --- | --- | --- |
| code | Number| 错误码,成功返回1000,否则返回大于1000的number值,可根据不同业务场景判断 |
| msg | String | 错误消息,如出现错误会给与提示 |
| data | String | 返回json格式数据,没有则为空数组 |
## 新闻接口地址:
~~~
POST http://yuzhounews.playone.cn/api/news/gets
~~~
## 新闻类型接口地址:
~~~
POST http://yuzhounews.playone.cn/api/news/newsTypes
~~~
## 调用
~~~
//测试案例,复制可用
function test(){
//包装数据
$all_params = [
'ticket'=>"news_api_test",//关注公众号“敏捷优讯”回复“票据”索取
'page'=>1,//起始页
'rows'=>15,//每页数量(最多50)
];
//加签
$all_params = $this->checkSignature($all_params);
//请求接口
$result = Tools::curl_post('http://yuzhounews.playone.cn/api/news/gets',$all_params);
//返回数据
var_dump($result);
}
/**
* desc:加签
* author:wh
* @param $all_params
* @return mixed
*/
protected function checkSignature($all_params)
{
//追加票据
$all_params['token'] = "ASbn56&1^%_";//关注公众号“敏捷优讯”回复“票据”索取
//将数据添加到临时变量
$tmpArr = [];
foreach ($all_params as $key=>$val){
$tmpArr[] = $key;
}
sort($tmpArr);
//按键名排序
//对关联数组按照键升序排序
ksort($tmpArr);
//拼接字符串
$str = "";
foreach ($tmpArr as $tmpkey){
foreach ($all_params as $param_key =>$param_val) {
if($tmpkey == $param_key){
$str.=($tmpkey."".$param_val);
}
}
}
$sign = md5(md5(md5($str)));
//参与加密,但不传输
unset($all_params['token']);
//追加加密串
$all_params['sign'] = $sign;//必须
return $all_params;
}
~~~
## 响应结果
```
{
"code": 1000,
"msg": "ok",
"data": [{
"id": 1998,
"title": "AMD台北电脑展发布会确定!CEO苏姿丰有望发布Zen3线程撕裂者处理器",
"description": "",
"url": "https://mbd.baidu.com/newspage/data/landingsuper?context=%7B%22nid%22%3A%22news_10580289984149905584%22%7D&n_type=1&p_from=3",
"newstype_id": 1,
"image": "",
"create_time": "2021-05-06 17:08:02"
},
{
"id": 1997,
"title": "吉利投资成立新能源商用车新公司",
"description": "",
"url": "https://mbd.baidu.com/newspage/data/landingsuper?context=%7B%22nid%22%3A%22news_10299975851104833176%22%7D&n_type=1&p_from=3",
"newstype_id": 1,
"image": "",
"create_time": "2021-05-06 17:07:01"
}
]
}
```