2014-01-15 21 views
0

www.z8games.com에서 로그인을 시도하고 설정 페이지로 이동합니다.이 코드는 제가 사용하고있는 코드이며 아래에 오류가 있습니다.cURL 로그인 및 리디렉션 [ASP.net 페이지]

<?php 
    $url = 'http://www.z8games.com/loging/globelogin.aspx?b=4&from='; 
    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_URL, $url); 
    $html = file_get_contents($url); 
    preg_match('~<input type=\"hidden\" name=\"__VIEWSTATE\" id=\"__VIEWSTATE\" value=\"(.*?)\" />~',$html,$viewstate); 
    preg_match('~<input type=\"hidden\" name=\"__EVENTVALIDATION\" id=\"__EVENTVALIDATION\" value=\"(.*?)\" />~',$html,$eventvalidation); 
    $vstate = $viewstate[1]; 
    $eval = $eventvalidation[1]; 
    $post_fields='__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=' . urlencode($vstate) . '&__EVENTVALIDATION=' . urlencode($eval) . '&tb_loginid=Heroboss123&tb_password=Droppers1&ib_login.x=11&ib_login.y=19'; 
    curl_setopt($ch, CURLOPT_HEADER, false); 
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); 
    curl_setopt($ch, CURLOPT_ENCODING, ""); 
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7s"); 
    curl_setopt($ch, CURLOPT_REFERER, $url); 
    curl_setopt($ch, CURLOPT_POST, 1); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields); 
    curl_setopt($ch, CURLOPT_COOKIEJAR, '/cookie.txt'); 
    curl_setopt($ch, CURLOPT_COOKIEFILE, '/cookie.txt'); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

    // Changing from page 
    curl_setopt($ch, CURLOPT_URL, "http://www.z8games.com/myaccount/myaccount.aspx"); 
    $store = curl_exec($ch); 
    echo $store; 

    curl_close($ch); 
?> 

그것은이 반환

error page

+0

제안 된대로 "디버그 모드"를 활성화하려고 했습니까? aspx 페이지에 액세스 할 수 있습니까? 'z8games'도 귀하의 사이트입니까? –

+2

z8games 이용 약관 위반으로 인해서는 안됩니다. –

+0

사이트에 로그인하는 것에 대해 아무 것도 표시되지 않습니다. – Joery

답변

0

당신은 잘못된 URL에 로그인 자격 증명을 게시하고 있습니다.

이 제거

curl_setopt($ch, CURLOPT_URL, "http://www.z8games.com/myaccount/myaccount.aspx"); 

을 그리고 사용이 :

curl_setopt($ch, CURLOPT_URL, $url); 

UPDATE :

가 다른 페이지에서 콘텐츠를 URL을 변경하고, 또한 HTTP를 사용하는 GET으로 요청하십시오. 현재 POST로 수행하고 있습니다. 따라서 :

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); 
curl_setopt($ch, CURLOPT_URL, "http://www.z8games.com/myaccount/myaccount.aspx"); 
+0

로그인하고 페이지를 변경하고 로그인해도 작동하지만 페이지에서 변경하면 작동하지 않습니다. – Joery

+0

답변을 업데이트했습니다. –

+0

좋아,하지만 그냥로드를 유지하고 결국 그것은 흰색 페이지를 반환합니다. – Joery