cURL call & accepting cookies

Hi There,

I currently run modx as my CMS. I’m trying to call another webpage as noted below. However, i keep on getting an ‘object moved’ error.

After some research ive discovered it’s because the webpage in question needs to create a cookies file.

How do i add the creation of cookies into the code? or how do i solve this situation?

<?php
// create cURL resource
$URL = “http://www.latesttraveloffers.com/ci/enter.asp?site=gi941&amp;dir=cruises&amp;ogid=10994”;
//Initl curl
$ch = curl_init();

//Set HTTP authentication option
curl_setopt($ch, CURLOPT_URL, $URL); // Load in the destination URL
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); //Normal HTTP request, not SSL
curl_setopt($ch, CURLOPT_USERPWD, “guest:test” ); // Pass the user name and password

// grab URL and pass it to the browser
$content = curl_exec($ch);

$result = curl_getinfo($ch);
// close cURL resource, and free up system resources
curl_close($ch);

echo $content;
echo $result;

?>

Use cURL’s cookiejar functions: http://curl.haxx.se/libcurl/php/examples/cookiejar.html

:slight_smile: