Answer the question
In order to leave comments, you need to log in
How to properly pass headers to curl?
how to properly pass headers to curl via php. I don't understand what's wrong, data is not returned. here is my code:
$myAccessToken = 'my-token';
$url = ' https://api.dropboxapi.com/2/users/get_space_usage ';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, ['Authorization: Bearer '.$myAccessToken, 'Content-Type: application/json']);
$curlData = curl_exec($curl);
curl_close($curl);
var_dump(json_decode($curlData, true));
Answer the question
In order to leave comments, you need to log in
$headers = array("Authorization: Bearer <ACCESS_TOKEN>",
"Content-Type: application/json");
$ch = curl_init('https://api.dropboxapi.com/2/users/get_space_usage');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, "null");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
Error in call to API function "users/get_space_usage": The given OAuth 2 access token is malformed.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question