D
D
Danil Lilov2019-12-01 13:32:03
PHP
Danil Lilov, 2019-12-01 13:32:03

Link shortener okl.lt - Authorization required, what to do?

Hello, in general, I can not solve the problem.
I'm trying to shorten the link through api, everything seems to be correct, but in echo - it says "Authorization required" to me.
There is no support on the site, I didn’t find exemple by api either, maybe something is wrong with my curl?.
The code itself:

$ch = curl_init();
  $headers = array("Access-Token" => "ТОКЕН");
  $urls = array("url" => "https://mail.ru/sadwq");
  curl_setopt($ch, CURLOPT_URL,"https://okl.lt/api/v1/make-short-url");
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  curl_setopt($ch, CURLOPT_POSTFIELDS,$urls);  //Post Fields
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  $server_output = curl_exec($ch);
  curl_close ($ch);
  print_r($server_output);

Api itself:
5de3967291715067700397.png
Please tell me, the devil will break his leg already, in this api. Headlines, I pass everything on, the post is there. No answer(

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mylistryx, 2019-12-01
@Penisoner

Apparently they have some glitches with the service. Specially registered, so five passwords came in confirmation, only one working. Okay, I made a request - authorization passes, but writes, Required parameters missing. With that I pass it on. I tried both CURL and from the phpStorm panel.
UPD! Won! The authorization header must be passed not as an array, but as a single line, i.e. $headers = ['Access-Token: TOKEN'];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question