Signing Requests

Hi,
I am trying to set up a call to an api that requires a signature but I think I am failing with the timing issue.
What the guide says about configure is as follows:

<?php

// Pay no attention to this statement.
// It's only needed if timezone in php.ini is not set correctly.
date_default_timezone_set("UTC");

// The current time. Needed to create the Timestamp parameter below.
$now = new DateTime();

// The parameters for our GET request. These will get signed.
$parameters = array(
    // The user ID for which we are making the call.
    'UserID' => 'look@me.com',

    // The API version. Currently must be 1.0
    'Version' => '1.0',

    // The API method to call.
    'Action' => 'FeedList',

    // The format of the result.
    'Format' => 'XML',

    // The current time formatted as ISO8601
    'Timestamp' => $now->format(DateTime::ISO8601)
);

// Sort parameters by name.
ksort($parameters);

// URL encode the parameters.
$encoded = array();
foreach ($parameters as $name => $value) {
    $encoded[] = rawurlencode($name) . '=' . rawurlencode($value);
}

// Concatenate the sorted and URL encoded parameters into a string.
$concatenated = implode('&', $encoded);

// The API key for the user as generated in the Seller Center GUI.
// Must be an API key associated with the UserID parameter.
$api_key = 'b1bdb357ced10fe4e9a69840cdd4f0e9c03d77fe';

// Compute signature and add it to the parameters.
$parameters['Signature'] =
    rawurlencode(hash_hmac('sha256', $concatenated, $api_key, false));

and

'Timestamp' => '2015-07-01T11:11:11+00:00'

So, I setup like this,




any idea how to make it work?
Best regards,

Do you have a link to the documentation?

1 Like

Hi @samliew

Blockquote Do you have a link to the documentation?

Sure, here is Do you have a link to the documentation?

Regards

Hello @ipoblete,

according to the doc, the parameters have to be URL Encoded. For the name of the fields, it’s fine, but for some of the values (the time and the email), it has to be encoded.

Should be something like that

For the output format (hex), I’m not 100% sure it’s what you need. If it still doesn’t work, try the others (text or base64)

Benjamin

2 Likes

Thank you @Benjamin_from_Make. It worked adding encondeURL
Best regards

3 Likes