I need to call a php page which is on an external website
https://www.test.com/addProduct?code=123123
passing a JSESSIONID
I wonder why when I try to print out the $curl info it seems that the only value that has been set is the URL:
$curl = curl_init();
try{
curl_setopt($curl, CURLOPT_URL, "https://www.test.com/addProduct?code=123123");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($curl, CURLINFO_HEADER_OUT, true);
curl_setopt($curl, CURLOPT_VERBOSE, true);
$headers = array();
$headers[] = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng";
$headers[] = "Connection: keep-alive";
$headers[] = "Cookie: JSESSIONID=" .$id;
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$information = curl_getinfo($curl);
print_r("<pre>");
print_r($information);
print_r("</pre>");
} catch (Exception $e) {
echo $e;
}
The result of the print_r($information) is this:
Array(
[url] => https://www.test.com/addProduct=123123
[content_type] =>
[http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0
[namelookup_time] => 0
[connect_time] => 0
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => -1
[upload_content_length] => -1
[starttransfer_time] => 0
[redirect_time] => 0
[redirect_url] =>
[primary_ip] =>
[certinfo] => Array
(
)
[primary_port] => 0
[local_ip] =>
[local_port] => 0
)
**** EDIT ****
I added the following row (I just forgot to paste it because it was outside the for loop)
$curl = curl_init();