有人可以帮我将这个curl命令行请求转换为PHP中的等效命令吗?非常感谢你!
curl 'https://utas.fut.ea.com/ut/game/fifa14/trade?tradeIds=3266885522' -H 'Cookie: CEM-session=2s6atve4hl9rdqlbleq8bhvgq5; s_sivo=GB%3AEACOM%3ANONE; s_ria=flash%2011%7Csilverlight%205.1; utag_main=_st:1380330504726$ses_id:1380328780078%3Bexp-session; __utma=103303007.320543511.1380328721.1380328721.1380328721.1; __utmc=103303007; __utmz=103303007.1380328721.1.1.utmcsr=easports.com|utmccn=(referral)|utmcmd=referral|utmcct=/uk/fifa/football-club; s_ppv=100; s_cc=true; s_nr1=1380328918707-NEW; s_sq=%5B%5BB%5D%5D' -H 'Origin: http://www.easports.com' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Host: utas.fut.ea.com' -H 'Accept-Language: en-US,en;q=0.8' -H 'User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.76 Safari/537.36' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'X-UT-SID: 7b8c91aa-083a-4c57-9176-21b53228bcbd' -H 'X-UT-PHISHING-TOKEN: 7869050555705646289' -H 'Referer: http://www.easports.com/iframe/fut/bundles/futweb/web/flash/FifaUltimateTeam.swf' -H 'X-UT-Embed-Error: true' -H 'Connection: keep-alive' -H 'X-HTTP-Method-Override: GET' --data-binary ' ' --compressed
我的尝试代码:http://pastebin.com/86VMFkK7
答案 0 :(得分:2)
<?php
$url = 'https://utas.fut.ea.com/ut/game/fifa14/trade?tradeIds=3266885522';
$headers = array(
's_sivo' => 'GB%3AEACOM%3ANONE',
's_ria' => 'flash%2011%7Csilverlight%205.1',
// .. add another headers
'Referer' => 'http://www.easports.com/iframe/fut/bundles/futweb/web/flash/FifaUltimateTeam.swf'
);
$options = array(
CURLOPT_HTTPHEADER => $headers, // Your custom headers
CURLOPT_COOKIEFILE => 'cookiefile.txt', // cURL or you can handled cookie content
CURLOPT_COOKIEJAR => 'cookiefile.txt', // Same as before
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => false, // don't return headers
CURLOPT_FOLLOWLOCATION => true, // follow redirects
CURLOPT_ENCODING => "", // handle all encodings
CURLOPT_USERAGENT => "my-custom-agent", // who am i
CURLOPT_AUTOREFERER => true, // set referer on redirect
CURLOPT_CONNECTTIMEOUT => 10, // timeout on connect
CURLOPT_TIMEOUT => 10, // timeout on response
CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
CURLOPT_SSL_VERIFYPEER => false // ***Disabled SSL Cert checks
);
$ch = curl_init( $url );
curl_setopt_array( $ch, $options );
$content = curl_exec( $ch );
$err = curl_errno( $ch );
$errmsg = curl_error( $ch );
$header = curl_getinfo( $ch );
curl_close( $ch );
echo $content;