function submit($file_path) { $url = ‘https://kfupload.alibaba.com/kupload’; $data = []; $data[‘scene’] = ‘aeMessageCenterV2ImageRule’; $data[‘name’] = ‘player.png’; $data[‘file’] = new CURLFile(realpath($file_path));
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120); curl_setopt($ch, CURLOPT_TIMEOUT, 120); $hothead[] = "Accept:application/json"; $hothead[] = "Accept-Encoding:gzip,deflate,sdch"; $hothead[] = "Accept-Language:zh-CN,zh;q=0.8"; $hothead[] = "Connection:close"; $ip = mt_rand(48, 140) . "." . mt_rand(10, 240) . "." . mt_rand(10, 240) . "." . mt_rand(10, 240); $hothead[] = ‘CLIENT-IP:’ . $ip; $hothead[] = ‘X-FORWARDED-FOR:’ . $ip; curl_setopt($ch, CURLOPT_HTTPHEADER, $hothead); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_USERAGENT, ‘Dalvik/2.1.0 (Linux; U; Android 10; ONEPLUS A5010 Build/QKQ1.191014.012)’); curl_setopt($ch, CURLOPT_ENCODING, "gzip"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $html = @curl_exec($ch); curl_close($ch); $json = @json_decode($html, true); if ($json[‘code’] == ‘0’) { @unlink($file_path); $file_path = $json[‘url’]; }
return $file_path; }
ua必须这个 |