2017-05-29 130 views
0

有沒有在PHP捲曲的任何命令,打印響應查詢字符串參數curl命令在PHP打印查詢字符串參數

下面是我的PHP代碼

 <?php 
     session_start(); 

     $ch = curl_init(); 
     curl_setopt($ch, CURLOPT_URL,"http://192.168.1.220/cgi-bin/handle_login.tcl"); 
    curl_setopt($ch, CURLOPT_POST, TRUE); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, 
     "user=admin&pw=admin&submit=Login&sid=' '");   
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: x-www-form-urlencoded')); 

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); 
    $response = curl_exec($ch); 
    echo "$response"; 
    curl_close ($ch); 
    ?> 

下面是標頭響應

 Request URL:http://localhost:8080/cgi-bin/frameset.tcl? 
     sid=3514275041172666092 
     Request Method:GET 
     Status Code:404 Not Found 
     Remote Address:[::1]:8080 
     Referrer Policy:no-referrer-when-downgrade 

響應頭

Accept-Ranges:bytes 
    Connection:Keep-Alive 
    Content-Language:en 
    Content-Type:text/html; charset=utf-8 
    Date:Mon, 29 May 2017 06:54:33 GMT 
    Keep-Alive:timeout=5, max=99 
    Server:Apache/2.4.18 (Win32) OpenSSL/1.0.2e PHP/7.0.4 
    Transfer-Encoding:chunked 
    Vary:accept-language,accept-charset 

請求頭

Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp, 
     */*;q=0.8 
    Accept-Encoding:gzip, deflate, sdch, br 
    Accept-Language:en-US,en;q=0.8 
    Connection:keep-alive 
    Cookie:PHPSESSID=hj7kbp4hp0pjq16m1tk7j3goo3; _ga=GA1.1.981975196.1489736033; XDEBUG_TRACE=XDEBUG_ECLIPSE 
    DNT:1 
    Host:localhost:8080 
    Referer:http://localhost:8080/nias/automate.php 
    Upgrade-Insecure-Requests:1 
    User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 

查詢字符串參數

sid=3514275041172666092 //need to print these value 
+0

您是否正在尋找此http://php.net/manual/en/function代碼.parse-str.php? –

+0

@SahilGulati ...即時通訊網址 body onLoad =「top.window.location ='/ cgi-bin/frameset.tcl?sid = 8892742251661757151'」...我需要提取sid – Pradeep

回答

0

由於輸出是在字符串格式和輸出保持恆定eachtime..needed找到在字符串中所需的字符的位置,並提取所需的值..

下面是

  $response= curl_exec($ch);//executes the curl 
      echo strpos("$response","variable_to_find")."<br/>";//know the position 
      $sid = substr($response,position,length);