人狠话不多,贴代码

function lol_photo()
{
    $lol = $this->http_get('https://game.gtimg.cn/images/lol/act/img/js/heroList/hero_list.js');
    $json_lol = json_decode($lol, 1)['hero'];
    $count_lol = rand(0, count($json_lol) - 1);
    $new_lol = substr($this->http_get('http://lol.qq.com/biz/hero/champion.js'), 50, -1);
    $json_lol = json_decode($new_lol, 1)['data'][$json_lol[$count_lol]['alias']];
    return 'https://game.gtimg.cn/images/lol/act/img/champion/' . $json_lol['image']['full'];
}
/**
 * GET请求
 * @param $url
 * @return bool|mixed
 */
public function http_get($url)
{
    $oCurl = curl_init();
    if (stripos($url, "https://") !== FALSE) {
        curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, FALSE);
    }
    curl_setopt($oCurl, CURLOPT_URL, $url);
    curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1);
    $sContent = curl_exec($oCurl);
    $aStatus = curl_getinfo($oCurl);
    curl_close($oCurl);
    if (intval($aStatus ["http_code"]) == 200) {
        return $sContent;
    } else {
        return false;
    }
}
Last modification:October 10th, 2020 at 11:59 am
如果觉得我的文章对你有用,请随意赞赏