tp5 聚合新闻接口调用

public function images(Request $request)
{
$news = file_get_contents("http://v.juhe.cn/toutiao/index?type=top&key=?自己的七牛云key");
$news = json_decode($news,true);
$data = $news['result']['data'];
$res = [];
foreach ($data as $v){
$res[] = [
'title'=>$v['title'],
'date'=>$v['date'],
'category'=>$v['category'],
'author_name'=>$v['author_name'],
'url'=>$v['url'],
'thumbnail_pic_s'=>imageCheck($v['thumbnail_pic_s'])=="pass"? $v['thumbnail_pic_s'] : "",//图片审核
'is_content'=>$v['is_content'],
];
}
\app\admin\model\News::insertAll($res);//添加入库
// News::insertAll($res);
return 11;
}



posted on 2021-12-02 11:07  少雄3306  阅读(44)  评论(0)    收藏  举报