I have an issue with CURL in the below code. The Hyperlink i'm an generating at the bottom if clicked is producing the correct output from the API (displaying an XML file in Browser)
However when sending via CURL no response is achieved. Any idea what i'm missing here? Is there anything i can do in terms of more error checking?
(Application Key Obviously Removed)
<?
$APIKey = '123456';
$maxResponseTime = '5000';
$maxResultCount = '5';
$Brand = 'OTB';
$DepartureAirport = 'LON';
$DestinationResort = 'Magaluf';
$DepartureDate = '2015-09-08';
$HolidayMinNights = '7';
$HolidayMaxNights = '7';
$DaysEitherSide = '3';
$PassengerCounts_Adults = '2';
$QueryString = "APIKey=".$APIKey."&maxResponseTime=".$maxResponseTime."&maxResultCount=".$maxResultCount."&Brand=".$Brand."&DepartureAirport=".$DepartureAirport."&DestinationCountry=&DestinationRegion=&DestinationResort=".$DestinationResort."&DepartureDate=".$DepartureDate."&HolidayMinNights=".$HolidayMinNights."&HolidayMaxNights=".$HolidayMaxNights."&Board=&StarRatingMin=&StarRatingMax=&DaysEitherSide=".$DaysEitherSide."&PassengerCounts_Adults=".$PassengerCounts_Adults."&PassengerCounts_Children=0&PassengerCounts_ChildAge=&PassengerCounts_Infants=0 ";
$QueryString2 = 'http://v2.feeds.distributenetwork.net/singlebrand.asmx/GetDeals?'.$QueryString;
// Get cURL resource
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true );
curl_setopt ($curl, CURLOPT_URL, $QueryString2);
// Send the request & save response to $resp
$resp = curl_exec($curl);
if(!curl_exec($curl)){
echo('Error: "' . curl_error($curl) . '" - Code: ' . curl_errno($curl));
}
// Close request to clear up some resources
curl_close($curl);
echo $resp;
///Generate Manual Link To Complete Get Request In Browser
echo '<br><br><a href='.$QueryString2.'>A Manual Link Which Works When Clicked</a>';
?>
echo curl_error($curl);return? php.net/manual/en/function.curl-error.php - If it's XML, wrap things in<pre></pre>andhtmlentities.