{"path":"/user/email/<email>","title":"[[global:404.title]]","bodyClass":"page-user page-user-email page-user-<email> page-status-404 user-guest"}
zxh
@zxh
Posts
-
Cannot authenticate API with PHP cURL -
Cannot authenticate API with PHP cURL/usr/bin/curl -H 'Authorization: Bearer <token>' --data _uid=0 <forums>/api/user/email/<email>
-
Cannot authenticate API with PHP cURL@pitaj Yes I have, doesn't appear to work either.
-
Cannot authenticate API with PHP cURLI'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);