以前拿的别人的接口,但是失效了,其实花几分钟看看也就写出来了,没有一点难度,于是就下手开始做了,浏览了下微博热搜榜。确实,改为了前后端分离的页面。
1、Json演示:
2、代码:
<?php
header('content-type:application/json;charset=utf-8');
$res = file_get_contents("https://weibo.com/ajax/statuses/hot_band");
$res = json_decode($res);
$resoulist = $res -> data ->band_list;
$array=array();
for ($i = 0; $i < count($resoulist); $i++) {
$array[$i]['title'] = $resoulist[$i]->word;
$array[$i]['url'] = "https://s.weibo.com/weibo?q=".$array[$i]['title'];
}
$res=json_encode(['data' => $array], JSON_UNESCAPED_UNICODE);
exit(json_encode($array, JSON_UNESCAPED_UNICODE));
?>
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
暂无评论内容