Answer the question
In order to leave comments, you need to log in
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));
}
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 )
Answer the question
In order to leave comments, you need to log in
can you try to point it out Content-Type: application/x-www-form-urlencoded
?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question