The code below is not working when I access the API by accessing this file and using cURL, It gives me following error:
Curl Error Results HTTP/1.1 403 Forbidden X-Mashery-Responder: mashery-web2-lax.mashery.com X-Mashery-Error-Code: ERR_403_DEVELOPER_INACTIVE Content-Type: text/xml Accept-Ranges: bytes Content-Length: 31 Server: Mashery Proxy Date: Mon, 29 Oct 2012 18:41:23 GMT Connection: keep-alive 403 Developer Inactive
and It is working when I access it directly through the link it generates. Can some one tell me if there is any problem with how I am using the cURL ?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
/**
* Initialize the cURL session
*/
$ch = curl_init();
$city = 'Seattle';
$departure = '11/03/2012';
$arrival = '11/08/2012';
$citycode='US';
$apiKey='***************';
$cid='55505';
$locale='en_US';
$currencyCode='USD';
$minorRev='16';
$customerSessionId='0ABAA874-27EB-E913-A4E2-7B0946904C6D';
$customerIpAddress=$_SERVER['REMOTE_ADDR'];
$customerUserAgent=$_SERVER['HTTP_USER_AGENT'];
$customerUserAgent=urlencode($customerUserAgent);
$url='http://api.ean.com/ean-services/rs/hotel/v3/list?minorRev='.$minorRev.'&cid='. $cid .'&apiKey='. $apiKey.'&customerUserAgent='.$customerUserAgent . '&locale='.$locale.'&currencyCode='.$currencyCode.'&_type=xml';
$xml='<HotelListRequest><city>';
$xml .= $city;
$xml .='</city><countryCode>';
$xml .= $citycode;
$xml .='</countryCode><arrivalDate>';
$xml .= $arrival;
$xml .='</arrivalDate><departureDate>';
$xml .= $departure;
$xml .='</departureDate></HotelListRequest>';
$main = $url .'&xml='. $xml;
echo $main;
/**
* Set the URL of the page or file to download.
*/
curl_setopt($ch, CURLOPT_URL, $main);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 65000);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/xml" ));
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
/**
* Ask cURL to return the contents in a variable instead of simply echoing them to the browser.
*/
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
/**
* Execute the cURL session
*/
$contents = curl_exec ($ch);
/**
* Close cURL session
*/
curl_close ($ch);
echo '<br /><br />Curl Error';
echo curl_error($ch);
echo '<br />Results <br />' . $contents;
?>
</body>
</html>