function get_curl($url) { global $curl, $ua; if (!$curl) { init_curl(); } curl_setopt($curl, CURLOPT_POSTFIELDS, null); curl_setopt($curl, CURLOPT_POST, false); curl_setopt($curl, CURLOPT_USERAGENT, $ua); curl_setopt($curl, CURLOPT_URL, $url); return $curl; }
function curl_get($uri) { global $url, $baseport, $oauth; $curl = init_curl($uri); $curlpass = str_replace("oauth:", "", $oauth); curl_setopt($curl, CURLOPT_HTTPHEADER, array('password: ' . $curlpass)); $result = curl_exec($curl); $eno = curl_errno($curl); $err = curl_error($curl); $status = curl_getinfo($curl, CURLINFO_HTTP_CODE); curl_close($curl); return array($result, $status, $eno, $err); }
} # 是否只是测试卡的有效性 $testonly = false; # apple id $apple_id = '*****@*****.**'; # 密码 $password = '******'; # 每个apple id会分配到不同的pxx-buy.itunes.apple.com,但是实测开 CURLOPT_FOLLOWLOCATION 就可以无视了,会有个307的头 $domain_suffix = '33'; # GUID,全16进制 $guid = 'xxxxxxxx.AF883918.00000000.F93819A9.CC0183D3.33019387.512309CA'; $login_url = "https://p{$domain_suffix}-buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/authenticate"; $login_referer = 'http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewGrouping?id=25204&mt=8&s=143441&pillIdentifier=iphone'; $login_post = 'matchineName=LOCALHOST&why=signin&attempt=1&createSession=true&guid=' . urlencode($guid) . '&appleId=' . urlencode($apple_id) . '&password='******'_cookie.txt'); curl_setopt($ch, CURLOPT_COOKIEJAR, '_cookie.txt'); curl_setopt($ch, CURLOPT_TIMEOUT, 60);