santunu23 0 Newbie Poster

I am trying to collect data from amazon market place web service in Scratchpad i get all the values.I am downloading php client library from mws developer website and try to run the code for display those files into browser


and according to the post we collect a code which is

$base_url = "";
$method = "POST";
$host = "";
$uri = "/Products/2011-10-01";

function amazon_xml($searchTerm) {

    $params = array(
        'AWSAccessKeyId' => AWS_ACCESS_KEY_ID,
        'Action' => 'ListMatchingProducts',
        'SellerId' => MERCHANT_ID,
        'SignatureVersion' => '2',
        'Version'=> '2011-10-01',
        'SignatureMethod' => 'HmacSHA256',
        'Query' => 'shoes');

        $params['Timestamp'] = gmdate('Y-m-d\TH:i:s\Z');

    // Sort the URL parameters
    $url_parts = array();
    foreach (array_keys($params) as $key) {
        $url_parts[] = $key . "=" . str_replace('%7E', '~', rawurlencode($params[$key]));


    // Construct the string to sign
    $url_string = implode("&", $url_parts);
    $string_to_sign = "POST\\n/Products/2011-10-01\n" . $url_string;

    // 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 = urlencode(base64_encode($signature));

    $url = "" . '?' . $url_string . "&Signature=" . $signature;
    $headers   = array("Content-Type: text/xml");

    $ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

//echo $url_string;
  curl_setopt($ch, CURLOPT_POSTFIELDS, $headers);

 $response = curl_exec($ch);
//$parsed_xml = simplexml_load_string($response);
//return ($parsed_xml);
return $response;
print_r $response;   

I don't get any return result and don't get the values any suggestions?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.