Is there any command in php curl to print response query string parameters
Below is my php code
<?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);
?>
below is header response
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
Response Headers
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
Request Headers
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
Query String Parameters
sid=3514275041172666092 //need to print these value
Since output was in string format and the output remains constant eachtime..needed to find the position of the required character in the string and extract the required value..
Below is the code
$response= curl_exec($ch);//executes the curl
echo strpos("$response","variable_to_find")."<br/>";//know the position
$sid = substr($response,position,length);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.