1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
| <?php
/*
* Author:小珏
* Uptime:2018-10-8,11:36
* 博客地址:https://qzone.work/
* 接口地址:https://qzone.work/api/randpic/
*/
$api = 'https://qzone.work/api/randpic/randpic.php';
$ret = json_decode ( get_curl ( $api, $data ), true );
header ( "Location:" . $ret ['imgurl'] );
function get_curl($url, $post = 0, $referer = 0, $cookie = 0, $header = 0, $ua = 0, $nobaody = 0) {
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_URL, $url );
curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt ( $ch, CURLOPT_SSL_VERIFYHOST, false );
$httpheader [] = "Accept:*/*";
$httpheader [] = "Accept-Encoding:gzip,deflate,sdch";
$httpheader [] = "Accept-Language:zh-CN,zh;q=0.8";
$httpheader [] = "Connection:close";
curl_setopt ( $ch, CURLOPT_HTTPHEADER, $httpheader );
if ($post) {
curl_setopt ( $ch, CURLOPT_POST, 1 );
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $post );
}
if ($header) {
curl_setopt ( $ch, CURLOPT_HEADER, true );
}
if ($cookie) {
curl_setopt ( $ch, CURLOPT_COOKIE, $cookie );
}
if ($referer) {
if ($referer == 1) {
curl_setopt ( $ch, CURLOPT_REFERER, 'http://m.qzone.com/infocenter?g_f=' );
} else {
curl_setopt ( $ch, CURLOPT_REFERER, $referer );
}
}
if ($ua) {
curl_setopt ( $ch, CURLOPT_USERAGENT, $ua );
} else {
curl_setopt ( $ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36" );
}
if ($nobaody) {
curl_setopt ( $ch, CURLOPT_NOBODY, 1 );
}
curl_setopt ( $ch, CURLOPT_ENCODING, "gzip" );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
$ret = curl_exec ( $ch );
curl_close ( $ch );
return $ret;
}
?>
|