簡體   English   中英

使用php curl中的用戶名和密碼登錄網站

[英]login into website using the username and password in php curl

我正面臨3天后仍無法解決的錯誤。 讓我知道我哪里錯了。 同樣,我需要登錄門戶網站並將其重定向到下一個網頁。

   url="http://gis.lntecc.com/BWSSBLnT/login.aspx?ReturnUrl=%2fbwssblnt%2fScada.aspx%3ffield1%3dKathriguppe%2cSW2DM0402%2c235505H073%2c450&field1=Kathriguppe,SW2DM0402,235505H073,450";

  $useragent="xyz";


    $ch = curl_init();


    curl_setopt($ch, CURLOPT_USERAGENT, $useragent);


   curl_setopt($ch, CURLOPT_URL, $url);
   curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);


    curl_setopt($ch, CURLOPT_USERPWD, 'abc:123');
   curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);



  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);


  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);


 curl_setopt ($ch, CURLOPT_POST, 1);

 curl_setopt ($ch, CURLOPT_POSTFIELDS, 'Login1_Username=abc&Login1_Password=123');


  curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);


  $store = curl_exec ($ch);
 echo $store;

  curl_close ($ch);

網站上的帖子字段名稱與您的代碼不同。

適當的名稱是Login1$UserNameLogin1$Password ,您需要查看name屬性,而不是ID。

在這種情況下,您的代碼應為:

curl_setopt ($ch, CURLOPT_POSTFIELDS, 'Login1$UserName=abc&Login1$Password=123');

嘿,使用php腳本登錄網頁的簡單方法是刪除網址,然后添加事物標頭(“位置: http ://gis.lntecc.com/bwssblnt/Scada.aspx?field1 = Kathriguppe%2cSW2DM0402%2c235505H073% 2c450" )

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM