· 6 years ago · Oct 04, 2019, 06:58 AM
1<?php
2
3// Pay no attention to this statement.
4// It's only needed if timezone in php.ini is not set correctly.
5date_default_timezone_set("UTC");
6
7// The current time. Needed to create the Timestamp parameter below.
8$now = new DateTime();
9
10// The parameters for our GET request. These will get signed.
11$parameters = array(
12 // The user ID for which we are making the call.
13 'UserID' => 'look@me.com',
14
15 // The API version. Currently must be 1.0
16 'Version' => '1.0',
17
18 // The API method to call.
19 'Action' => 'FeedList',
20
21 // The format of the result.
22 'Format' => 'XML',
23
24 // The current time formatted as ISO8601
25 'Timestamp' => $now->format(DateTime::ISO8601)
26);
27
28// Sort parameters by name.
29ksort($parameters);
30
31// URL encode the parameters.
32$encoded = array();
33foreach ($parameters as $name => $value) {
34 $encoded[] = rawurlencode($name) . '=' . rawurlencode($value);
35}
36
37// Concatenate the sorted and URL encoded parameters into a string.
38$concatenated = implode('&', $encoded);
39
40// The API key for the user as generated in the Seller Center GUI.
41// Must be an API key associated with the UserID parameter.
42$api_key = 'b1bdb357ced10fe4e9a69840cdd4f0e9c03d77fe';
43
44// Compute signature and add it to the parameters.
45$parameters['Signature'] =
46 rawurlencode(hash_hmac('sha256', $concatenated, $api_key, false));