· 7 years ago · Mar 06, 2018, 04:48 PM
1$href = 'https://delivery.yandex.ru/api/last/getSenderOrders';
2$methodKey = '440b1fad8641995b1257f3034534b470a447287b37234534579b63cef3c14de28d015db8ac1e';
3$client_id = '55781';
4$sender_id = '32654';
5
6$date = array();
7$secret_key = md5(getPostValues($date) . $methodKey);
8$date2 = array(
9'secret_key' => $secret_key,
10'client_id' => $client_id,
11'sender_id' => $sender_id,
12);
13$my = http_build_query($date2);
14$href2 = 'https://delivery.yandex.ru/api/last/getSenderOrders?'.$my;
15$curl = curl_init();
16curl_setopt($curl, CURLOPT_URL, $href2);
17curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
18curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
19curl_setopt($curl, CURLOPT_HTTPHEADER, array(
20'Content-Type: application/x-www-form-urlencoded',
21) );
22curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($date));
23$out = curl_exec($curl);
24$er = curl_error($curl);
25 curl_close($curl);
26 print_r(json_decode($out));
27
28function getPostValues($data)
29{
30 if (!is_array($data)) return $data;
31 ksort($data);
32 return join('', array_map(function($k)
33 {
34 return getPostValues($k);
35 },
36 $data));
37 }