php 获取微博
日期: January 8, 2019 作者:网站维护
用调试工具调试手机web版的weibo,可以找到JSON格式的weibo数据。
file_get_contents 获取数据,json_decode 解码JSON成PHP的对象,foreach 遍历一下输出每条微博。
$json = file_get_contents('https://m.weibo.cn/api/container/getIndex?type=uid&value=1668277257&containerid=1076031668277257');
$obj = json_decode($json);
//var_dump($obj);
foreach ($obj->data->cards as $cards){
if (isset($cards->mblog->text)){
echo $cards->mblog->text;
echo '<span style="color:red; margin-left:1em">';
echo $cards->mblog->created_at;
echo '</span>';
echo "<hr/>";
}
}
广告内容为平台自动生成