2014-09-18 2 views
1

기기 ID가 990000288326509 인 http://www.verizonwireless.com/b2c/nso/enterDeviceId.do 으로 메일 요청을 보냅니다. 웹 사이트에서 응답은 괜찮습니다. 그러나 컬 응답에서 Null을 보여줍니다. 내 코드는curl 요청시 Null 응답이 발생합니다.

$send = array('callCount'=>'1', 
    'page'=>'http://localhost/test/test2.php', 
    'httpSessionId'=>'xnTQJZtTRy2LGskT7ykL1J2hC0WR1Z8zDQG4TyQywZTBhQjhnfQQ!2038153311!cis-napp6!5101!-1', 
    'scriptSessionId'=>'1BD99809C2C77639811B3AD5E7D146CD412', 
    'c0-scriptName'=>'nsoAjaxService', 
    'c0-methodName'=>'validateDevice', 
    'c0-id'=>'0', 
    'c0-param0'=>'string:990000288326509', 
    'c0-param1'=>'null:null', 
    'batchId'=>'1'); 

foreach ($send as $key => $value) 
{ 
$post_items[] = $key . '=' . $value; 
} 
$post_string = implode ('&', $post_items); 

$headers = array(
    'Referer:http://www.verizonwireless.com/b2c/nso/enterDeviceId.do', 
    'User-Agent:Mozilla/5.1 (Windows NT 5.1; rv:21.0) Gecko/20100101 Firefox/21.0', 
      'Content-Type:text/plain; charset=UTF-8', 
    'Connection:keep-alive', 
    'Pragma:no-cache', 
    'Cache-Control:no-cache', 
    'Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 

); 


$curl_connection =curl_init('http://www.verizonwireless.com/b2c/dwr/call/plaincall/nsoAjaxService.validateDevice.dwr'); 
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30); 
curl_setopt($curl_connection, CURLOPT_USERAGENT, 
"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:32.0) Gecko/20100101 Firefox/32.0"); 
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false); 
curl_setopt($curl_connection, CURLOPT_HEADER, 1); 
curl_setopt($curl_connection, CURLOPT_HTTPHEADER, $headers); 
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1); 

curl_setopt($curl_handle, CURLOPT_COOKIE, "fsr.a=1410881803154; NSC_xxx_hwt=ffffffff8ab44cd945525d5f4f58455e445a4a420000; GLOBALID=Asf9qgT2Y7fIZG2y%2F3OvmXqIPRlDopoQXYP5FSPeSsqJhGSoSzM014uwEamRWLG%2B; JSESSIONIDB2C=TgzGJYYF5VDjrL42K7tMtnM3kLVMZgPdgcsZWGXpcwqFPGmyGQHM!949298941!cis-napp14!5102!-1; B2CP=31499; SESSION_VALUE=TgzGJYYF5VDjrL42K7tMtnM3kLVMZgPdgcsZWGXpcwqFPGmyGQHM!949298941!cis-napp14!5102!-1!1410881765754; TIME_CHECKER=1410881765756; ZIP_CONFIRMED=false; CARTVIEW=FALSE; ZIPCODE=92618; CITY=Irvine; STATE=CA; __g_u=167026737466531_0; __g_c=c%3A167026737466531%7Cd%3A0%7Ca%3A0; mbox=check#true#1410881829|session#1410881766564-453590#1410883629|PC#1410881766564-453590.20_06#1418657769; s_sess=%20s_cc%3Dtrue%3B%20ppv_o%3D%252Fstore%252Fnso%252Fadd%2520new%2520device%252Fcheck%2520device%2520eligibility%3B%20s_ppv%3D%252Fstore%252Fnso%252Fadd%252520new%252520device%252Fcheck%252520device%252520eligibility%252C67%252C40%252C1533%3B%20s_sq%3Dvzwiglobal%252Cvzwiconsumer%253D%252526pid%25253D%2525252Fstore%2525252Fnso%2525252Fadd%25252520new%25252520device%2525252Fcheck%25252520device%25252520eligibility%252526pidt%25253D1%252526oid%25253Dfunctiononclick(event)%2525257BvzwSc.trackLink('CheckDevice')%2525253B%2525257D%252526oidt%25253D2%252526ot%25253DSUBMIT%3B; s_pers=%20s_lastvisit%3D1410881766961%7C1505489766961%3B%20s_nr5%3D1410881803451-New%7C1442417803451%3B; s_vi=[CS]v1|2A0C2C7385078C24-4000010B40018ED7[CE]; invodoViewer=CEay6RLDSRPy1PPo7aTognAYOKQyLZOy2ws52F8MLFCD; invodoVisitor=Bj6LpHdRCHIF4bIKefCK050; MP_LANG=en; 44153975-VID=11352070703620; 44153975-SKEY=1589713448007833473; HumanClickSiteContainerID_44153975=Secondary2"); 

curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string); 
$result = curl_exec($curl_connection); 

echo "<pre>";print_r($result); 


curl_close($curl_connection); 

누구든지 도움을 줄 수 있습니다. 귀하의 도움을 주시면 감사하겠습니다. 감사

편집

내 컬 명령은 잘못 CURL 옵션을 사용

curl 'http://www.verizonwireless.com/b2c/dwr/call/plaincall/nsoAjaxService.validateDevice.dwr' -H 'Origin: http://www.verizonwireless.com' -H 'Accept-Encoding: gzip,deflate' -H 'Accept-Language: en-US,en;q=0.8' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.94 Safari/537.36' -H 'Content-Type: text/plain' -H 'Accept: */*' -H 'Referer: http://www.verizonwireless.com/b2c/nso/enterDeviceId.do?&zipRdr=y' -H $'Cookie: GLOBALID=yu4VNGEo2XDiIWxfLH10CxJ9NJYTVm6FpqqVdRkCJAlNHGK4uII1pf4pQcOaKSRI; SESSION_VALUE=wpqBJZ4TQ2wmp2SRh4dhNyd5Z5nR9tz4s7vT4yxJBhvFx1LVVQwh!1653654758!cis-eapp11!5105!-1!1410971854877; TIME_CHECKER=1410971854880; ZIP_CONFIRMED=false; ZIPCODE=06850; CITY=Norwalk; STATE=CT; NSC_xxx_hwt=ffffffffa17bccd945525d5f4f58455e445a4a420000; __g_u=244275901657417_0; __g_c=c%3A244275901657417%7Cd%3A0%7Ca%3A0; mbox=check#true#1410971927|session#1410971866487-28327#1410973727|PC#1410971866487-28327.22_13#1418747868; invodoViewer=ATi9UY9WHYranfrSWLfSPN; invodoVisitor=DHTZzmIAcmyToDy2XY02rX; MP_LANG=en; 44153975-VID=113260187695857; 44153975-SKEY=7341039846374976868; HumanClickSiteContainerID_44153975=Secondary1; JSESSIONIDB2C=RT27JZMLXhdcx6k0hzcCGdNPxVwQ77wCgwhYH4QBKhyXpPJlLy8v!1653654758!cis-eapp11!5105!-1; B2CP=55557; s_vi=[CS]v1|2A0CDC6E8501169F-4000010340002499[CE]; s_pers=%20s_lastvisit%3D1410977003953%7C1505585003953%3B%20s_nr5%3D1410977041660-Repeat%7C1442513041660%3B; s_sess=%20s_cc%3Dtrue%3B%20ppv_o%3D%252Fstore%252Fnso%252Fadd%2520new%2520device%252Fcheck%2520device%2520eligibility%2520error%3B%20s_ppv%3D%252Fstore%252Fnso%252Fadd%252520new%252520device%252Fcheck%252520device%252520eligibility%252C68%252C16%252C1543%3B%20s_sq%3Dvzwiglobal%252Cvzwiconsumer%253D%252526pid%25253D%2525252Fstore%2525252Fnso%2525252Fadd%25252520new%25252520device%2525252Fcheck%25252520device%25252520eligibility%25252520error%252526pidt%25253D1%252526oid%25253Dfunctiononclick(event)%2525257BvzwSc.trackLink(\'CheckDevice\')%2525253B%2525257D%252526oidt%25253D2%252526ot%25253DSUBMIT%3B' -H 'Connection: keep-alive' --data-binary $'callCount=1\npage=/b2c/nso/enterDeviceId.do?&zipRdr=y\nhttpSessionId=RT27JZMLXhdcx6k0hzcCGdNPxVwQ77wCgwhYH4QBKhyXpPJlLy8v!1653654758!cis-eapp11!5105!-1\nscriptSessionId=6B589450F498804B5ACD520345700D4E929\nc0-scriptName=nsoAjaxService\nc0-methodName=validateDevice\nc0-id=0\nc0-param0=string:990000288326509\nc0-param1=null:null\nbatchId=4\n' --compressed 

답변

0

입니다. 지정된 CURL 명령에 따라 text/plain Content-Type을 사용하여 2 진 데이터를 전송합니다. 따라서 양식 데이터로 데이터를 작성하지 말고 그대로 전달하고 Content-Type 헤더를 text/plain으로 설정해야합니다. CURLOPT_COOKIE 옵션을 설정하면 정의되지 않은 $curl_handle 변수를 CURL 핸들로 전달합니다.

그래서 코드는 다음과 같아야합니다

여전히
$data_str = 'callCount=1 
page=http://localhost/test/test2.php', 
httpSessionId=xnTQJZtTRy2LGskT7ykL1J2hC0WR1Z8zDQG4TyQywZTBhQjhnfQQ!2038153311!cis-napp6!5101!-1', 
scriptSessionId=1BD99809C2C77639811B3AD5E7D146CD412', 
c0-scriptName=nsoAjaxService', 
c0-methodName=validateDevice', 
c0-id=0', 
c0-param0=string:990000288326509', 
c0-param1=null:null', 
batchId=1 
'; 

$cookie_str = "fsr.a=1410881803154; NSC_xxx_hwt=ffffffff8ab44cd945525d5f4f58455e445a4a420000; GLOBALID=Asf9qgT2Y7fIZG2y%2F3OvmXqIPRlDopoQXYP5FSPeSsqJhGSoSzM014uwEamRWLG%2B; JSESSIONIDB2C=TgzGJYYF5VDjrL42K7tMtnM3kLVMZgPdgcsZWGXpcwqFPGmyGQHM!949298941!cis-napp14!5102!-1; B2CP=31499; SESSION_VALUE=TgzGJYYF5VDjrL42K7tMtnM3kLVMZgPdgcsZWGXpcwqFPGmyGQHM!949298941!cis-napp14!5102!-1!1410881765754; TIME_CHECKER=1410881765756; ZIP_CONFIRMED=false; CARTVIEW=FALSE; ZIPCODE=92618; CITY=Irvine; STATE=CA; __g_u=167026737466531_0; __g_c=c%3A167026737466531%7Cd%3A0%7Ca%3A0; mbox=check#true#1410881829|session#1410881766564-453590#1410883629|PC#1410881766564-453590.20_06#1418657769; s_sess=%20s_cc%3Dtrue%3B%20ppv_o%3D%252Fstore%252Fnso%252Fadd%2520new%2520device%252Fcheck%2520device%2520eligibility%3B%20s_ppv%3D%252Fstore%252Fnso%252Fadd%252520new%252520device%252Fcheck%252520device%252520eligibility%252C67%252C40%252C1533%3B%20s_sq%3Dvzwiglobal%252Cvzwiconsumer%253D%252526pid%25253D%2525252Fstore%2525252Fnso%2525252Fadd%25252520new%25252520device%2525252Fcheck%25252520device%25252520eligibility%252526pidt%25253D1%252526oid%25253Dfunctiononclick(event)%2525257BvzwSc.trackLink('CheckDevice')%2525253B%2525257D%252526oidt%25253D2%252526ot%25253DSUBMIT%3B; s_pers=%20s_lastvisit%3D1410881766961%7C1505489766961%3B%20s_nr5%3D1410881803451-New%7C1442417803451%3B; s_vi=[CS]v1|2A0C2C7385078C24-4000010B40018ED7[CE]; invodoViewer=CEay6RLDSRPy1PPo7aTognAYOKQyLZOy2ws52F8MLFCD; invodoVisitor=Bj6LpHdRCHIF4bIKefCK050; MP_LANG=en; 44153975-VID=11352070703620; 44153975-SKEY=1589713448007833473; HumanClickSiteContainerID_44153975=Secondary2"; 

$headers = array(
    'Referer:http://www.verizonwireless.com/b2c/nso/enterDeviceId.do', 
    'User-Agent:Mozilla/5.1 (Windows NT 5.1; rv:21.0) Gecko/20100101 Firefox/21.0', 
    'Content-Type:text/plain; charset=UTF-8', 
    'Connection:keep-alive', 
    'Pragma:no-cache', 
    'Cache-Control:no-cache', 
    'Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 
); 

$curl_connection =curl_init('http://www.verizonwireless.com/b2c/dwr/call/plaincall/nsoAjaxService.validateDevice.dwr'); 
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30); 
curl_setopt($curl_connection, CURLOPT_USERAGENT, 
"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:32.0) Gecko/20100101 Firefox/32.0"); 
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false); 
curl_setopt($curl_connection, CURLOPT_HEADER, 1); 
curl_setopt($curl_connection, CURLOPT_HTTPHEADER, $headers); 
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1); 
curl_setopt($curl_connection, CURLOPT_COOKIE, $cookie_str); 
curl_setopt($curl_connection, CURLOPT_POST, true); 
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $data_str); 
$result = curl_exec($curl_connection); 
curl_close($curl_connection); 

echo "<pre>"; 
print_r($result); 
+0

가 null – Vinie

+0

세트를 수신'CURLINFO_HEADER_OUT' 옵션 및 출력'curl_close''전에 결과 curl_getinfo' :'에서 print_r (curl_getinfo ($ curl_connection을)); ' – hindmost

관련 문제