|
|
Disappointed by Amazon.com and the Associates program?
Please consider
Shareasale

Shareasale manages affiliate programs for thousands of merchants. The site makes it easier
to apply to programs and create links. And simple-to-use datafeeds are offered by most
merchants.
|
|
|
|
Using CURL to Get Results from ECS
The following PHP function allows you to fetch results from an A2S query including the status code. It returns the text returned from the URL. It also returns the HTTP status code and the HTTP headers.
function getAmazonPage($url, &$code, &$headers)
{
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_USERAGENT, ' Your Name /1.0 (+ http://www. yourdomain.com /)');
curl_setopt ($ch, CURLOPT_HEADER, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_TIMEOUT, 120);
$result = curl_exec ($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$hsize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$headers = substr($result, 0, $hsize - 2);
$result = substr($result, $hsize);
curl_close($ch);
return $result;
}
|
To use the function, do something like:
$result = getAmazonPage($rest_url, $code, $header);
if ($code == 500 || $code == 503)
{
... handle error
}
else
{
... process XML
}
|
|
|
|
|