Answer the question
In order to leave comments, you need to log in
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);
Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question