Cannot authenticate API with PHP cURL
Unsolved
Technical Support
-
I'm trying to make use of the NodeBB API on a PHP page, but cannot seem to get authentication using a bearer token working.
This is my code so far
$url = '<forums>/api/user/email/<email>'; $headers = ['Authorization: Bearer <token>']; $post = ['_uid' => '0']; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post)); $response = curl_exec($ch); $data = json_decode($response, true); curl_close($ch); print_r($data);
-
Have you tried curl from the command line?
-
@zxh share the curl command you used please.
-
@zxh and what response do you get?
-
@julian mind taking a look?
Copyright © 2024 NodeBB | Contributors