If you only need these two headers, use cURL% w / o. ;)
That way it would look like:
curl -H "Authorization: {String}" -H "Content-Type: application/json;charset=UTF-8" https://site-alvo.com
In PHP, however, it would look like this:
// Inicia o CURL, definindo o site alvo:
$ch = curl_init('https://site-alvo.com');
// Adiciona as opções:
curl_setopt_array($ch, [
// Equivalente ao -H:
CURLOPT_HTTPHEADER => [
'Authorization: {String}',
'Content-Type: application/json;charset=UTF-8',
],
// Permite obter resposta:
CURLOPT_RETURNTRANSFER => true
]);
// Executa:
$resultado = curl_exec($ch);
// Encerra CURL:
curl_close($ch);
In this way get the answer using:
var_dump($resultado);
However possibly there is an error in the question itself. The -H
has the default Authorization
, this was determined by the W3C .
For example, in the case of HTTP Auth Basic, default:
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
This is Authorization: <type> <credentials>
Authorization:
+ Basic
.
In other cases, defaults to BASE64(Login:Senha)
, which comes from OAuth2, here you have the details of it .
Personally I do not know a type of:
Authorization: JSON {}
Possibly the previous call you make returns a JSON as follows:
{
"access_token":"mF_9.B5f-4.1JqM",
"token_type":"Bearer",
"expires_in":3600,
"refresh_token":"tGzv3JOkF0XG5Qx2TlKWIA"
}
This is exactly the example of specified here , so you should use Bearer Token
in :
Authorization: Bearer mF_9.B5f-4.1JqM
But without specific documentation it is impossible to guess!