今天打开好久不用的QQ空间,发现了一些好看的壁纸,这些壁纸很阳光,感觉又回到了青春,想了想要不我也写个抓取腾讯QQ空间图片接口的,毕竟这么好看的东西不要浪费嘛!
下面贴代码

<?php

/** 
* QQ空间随机壁纸
* @author Reaper <a@0oo.ren> 
* @request https://www.52bz.la
* @return url
*/ 

//访问图片配置文件
$url = geturl('https://qzonestyle.gtimg.cn/qzone/qzactStatics/configSystem/data/179/config1.js');
//删除多余字符串
$data = substr($url,'25','-158');
//解析Json
$data = json_decode($data,1)['list'];
//获取图片数量
$num = count($data)-1;
//跳转图片
header("location:".$data[rand(0,$num)]['bg']);

//curl
function geturl($url)
{
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36');
    curl_setopt($ch, CURLOPT_TIMEOUT, 30);
    $content = curl_exec($ch);
    curl_close($ch);
    return ($content);
}
Last modification:December 13th, 2019 at 03:51 pm
如果觉得我的文章对你有用,请随意赞赏