C
C
Counter2018-02-16 19:01:04
PHP
Counter, 2018-02-16 19:01:04

The Yandex.Delivery api does not want to work. What am I doing wrong?

I want to get a list of orders from Yandex.delivery account. Forming a request for documentation:

$href = 'https://delivery.yandex.ru/api/last/getSenderOrders';
$methodKey = 'Тут key из личного кабинета';
$client_id = 'Тут клиент id';
$sender_id = 'Тут аналогично';
$post = array(
    'client_id' => $client_id,
    'sender_id' => $sender_id,
);
$secret_key = md5(getPostValues($post) . $methodKey);

$date = array(
  'secret_key' => $secret_key,
  'client_id' => $client_id,
  'sender_id' => $sender_id,
);
  $curl = curl_init();
     curl_setopt($curl, CURLOPT_URL, $href);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
     curl_setopt($curl, CURLOPT_HTTPHEADER, array(
         'Content-Type: application/json',
     ) );
     curl_setopt($curl, CURLOPT_POSTFIELDS, $date2);
     $out = curl_exec($curl);
     $er = curl_error($curl);
     $response = json_decode($out);
     curl_close($curl);
function getPostValues($data)
  {    
    if (!is_array($data)) return $data;    
    ksort($data);    
    return join('', array_map(function($k)
                                {
                                  return getPostValues($k);
                                }, 
                    $data));
  }

In response I get an error:
stdClass Object ( [status] => error [data] => stdClass Object ( [errors] => stdClass Object ( [client_id] => Не удалось авторизоваться с указанным client_id [sender_id] => Указан некорректный sender_id [secret_key] => Заполните это поле [resourceKey] => Заполните это поле [hashValid] => Значение должно быть истинным. ) ) [error] => ERROR_WRONG_PARAMS )

With this sender_id and client_id exactly correct, I checked it 2 times.
Tell me where am I stupid? Google gave no answers.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Epifanov, 2018-02-16
@kacheleff

can you try to point it out Content-Type: application/x-www-form-urlencoded?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question