Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在aspx页面上执行php curl请求时找不到404_Php_Asp.net_Curl - Fatal编程技术网

在aspx页面上执行php curl请求时找不到404

在aspx页面上执行php curl请求时找不到404,php,asp.net,curl,Php,Asp.net,Curl,我正在尝试使用PHP curl登录.aspx页面。现在,我正在抓取登录页面以获取VIEWSTATE并编写正确的url来发出请求,之后还有一个提交字段并登录的curl请求。此curl调用返回404错误。我已经尝试用另一个curl发出另一个curl请求,但它会重定向到登录页面。 我哪里错了 include('../dom/simple_html_dom.php'); $ckfile = tempnam ("/tmp", "CURLCOOKIE"); $url = 'http

我正在尝试使用PHP curl登录.aspx页面。现在,我正在抓取登录页面以获取VIEWSTATE并编写正确的url来发出请求,之后还有一个提交字段并登录的curl请求。此curl调用返回404错误。我已经尝试用另一个curl发出另一个curl请求,但它会重定向到登录页面。 我哪里错了

    include('../dom/simple_html_dom.php');
    $ckfile = tempnam ("/tmp", "CURLCOOKIE"); 
    $url = 'http://www.EXAMPLE.com/Shop/Login.aspx';

//FIRST CALL TO GRAB THE VIEWSTATE VALUE
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); // Accepts all CAs 
    curl_setopt($ch, CURLOPT_URL, $url); 
    curl_setopt($ch, CURLOPT_COOKIEJAR, $ckfile);
    curl_setopt($ch, CURLOPT_COOKIEFILE, $ckfile); //Uses cookies from the temp file 
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // Tells cURL to follow redirects 
    $output = curl_exec($ch);

    $html = str_get_html($output);

//GRABBING THE VALUES
    $evttarget  = 'LogonBox%24btnLogin';
    $evtarg     = '';
    $viewstate  = urlencode($html->find('input#__VIEWSTATE')[0]->value);
    $viewgen    = urlencode($html->find('input#__VIEWSTATEGENERATOR')[0]->value);
    $username   = 'MYUSERNAME';
    $password   = 'MYPASSWORD';

//COMPOSING THE URL 
    $url = 'http://www.EXAMPLE.com/Shop/Login.aspx?__EVENTTARGET='.$evttarget.'&__EVENTARGUMENT='.$evtarg.'&__VIEWSTATE='.$viewstate.'&__VIEWSTATEGENERATOR='.$viewgen.'&LogonBox%24txtUsername='.$username.'&LogonBox%24txtPassword='.$password;

//LOGIN REQUEST
    $ch = curl_init();
    print $url;
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); // Accepts all CAs 
    curl_setopt($ch, CURLOPT_URL, $url); 
    curl_setopt($ch, CURLOPT_COOKIEJAR, $ckfile);
    curl_setopt($ch, CURLOPT_COOKIEFILE, $ckfile); //Uses cookies from the temp file
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // Tells cURL to follow redirects 
    $output = curl_exec($ch);

THIS RETURNS A 404 ERROR

我尝试过编写url并将其粘贴到浏览器的地址栏中,它也会返回404错误,因此我认为问题可能与标题有关,对吗?我尝试过编写url并将其粘贴到浏览器的地址栏中,它也会返回404错误,因此我想问题可能与标题有关,我说得对吗?