I do not know this API, but the header I think it's like this:
Authorization: Basic [login e senha em base64]
If is of type Basic
, to summarize it works like this:
Authorization: [tipo] [credenciais]
In the doc say this:
Each store has its own authentication key to be used in the HTTP Authorization header, which should be requested from your account manager at 00K.
So I think the manager can tell you if it's actually Basic
, if it's basic and using PHP you can use it like this:
$usuario = 'usuario';
$senha = 'senha';
$header = 'Authorization: Basic ' . base64_encode($usuario . ':' . $senha);
But this is what I said, it's just to be of type Basic
if it's another type, forget it, that's not how it works.
Maybe it really is Basic
follow some examples below:
Using Basic with file_get_contents
$usuario = 'usuario';
$senha = 'senha';
$url = 'http://api.00k.srv.br/';
$header = 'Authorization: Basic ' . base64_encode($usuario . ':' . $senha) . "\r\n"
'Content-Type: application/json;charset=UTF-8';
$context = stream_context_create(array(
'http' => array(
'header' => $header
)
)
);
$homepage = file_get_contents($url, false, $context);
var_dump($data); //Visualiza a resposta
Using Basic with curl
$usuario = 'usuario';
$senha = 'senha';
$url = 'http://api.00k.srv.br/';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json;charset=UTF-8'
));
curl_setopt($ch, CURLOPT_USERPWD, $username . ':' . $password);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
$data = curl_exec($ch);
if($data === false) {
echo 'Erro ao executar o CURL: ' . curl_error($ch);
} else {
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpcode !== 200) {
echo 'Erro ao requisitar o servidor';
}
}
curl_close($ch);
var_dump($data); //Visualiza a resposta