Note that there are some explanatory texts on larger screens.

plurals
  1. POAmazon Product API with PHP
    primarykey
    data
    text
    <p>I'm trying to integrate Amazon Product API into my website and came across several posts that helped me construct the URL. Only problem is when I execute the code below I get the following error. Am I doing something wrong?</p> <blockquote> <p><strong>Internal Server Error</strong> The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, awsadmin@amazon.com and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log.</p> </blockquote> <pre><code>$AWS_ACCESS_KEY_ID = "[myaccesskeyhere]"; $AWS_SECRET_ACCESS_KEY = "[mysecretkeyhere]"; $base_url = "http://ecs.amazonaws.com/onca/xml?"; $url_params = array('Operation'=&gt;"ItemSearch",'Service'=&gt;"AWSECommerceService", 'AWSAccessKeyId'=&gt;$AWS_ACCESS_KEY_ID,'AssociateTag'=&gt;"yourtag-10", 'Version'=&gt;"2006-09-11",'Availability'=&gt;"Available",'Condition'=&gt;"All", 'ItemPage'=&gt;"1",'ResponseGroup'=&gt;"Images,ItemAttributes,EditorialReview", 'Keywords'=&gt;"Amazon"); // Add the Timestamp $url_params['Timestamp'] = gmdate("Y-m-d\TH:i:s.\\0\\0\\0\\Z", time()); // Sort the URL parameters $url_parts = array(); foreach(array_keys($url_params) as $key) $url_parts[] = $key."=".$url_params[$key]; sort($url_parts); // Construct the string to sign $string_to_sign = "GET\necs.amazonaws.com\n/onca/xml\n".implode("&amp;",$url_parts); $string_to_sign = str_replace('+','%20',$string_to_sign); $string_to_sign = str_replace(':','%3A',$string_to_sign); $string_to_sign = str_replace(';',urlencode(';'),$string_to_sign); // Sign the request $signature = hash_hmac("sha256",$string_to_sign,$AWS_SECRET_ACCESS_KEY,TRUE); // Base64 encode the signature and make it URL safe $signature = base64_encode($signature); $signature = str_replace('+','%2B',$signature); $signature = str_replace('=','%3D',$signature); $url_string = implode("&amp;",$url_parts); $url = $base_url.$url_string."&amp;Signature=".$signature; print $url; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 15); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); $xml_response = curl_exec($ch); echo $xml_response; </code></pre> <p><strong>EDIT</strong></p> <p><strong>THE ABOVE CODE NOW WORKS...I WAS MISSING A "?" after the BASE URL</strong></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload