Correct way to set Bearer token with CURL

前端 未结 7 858
悲哀的现实
悲哀的现实 2020-11-30 22:12

I get my bearer token from an API end point and set the following:

$authorization = \"Bearer 080042cad6356ad5dc0a720c18b53b8e53d4c274\"

Nex

7条回答
  •  -上瘾入骨i
    2020-11-30 22:43

     "your api goes here",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => array(
    "Authorization: Bearer eyJ0eciOiJSUzI1NiJ9.eyJMiIsInNjb3BlcyI6W119.K3lW1STQhMdxfAxn00E4WWFA3uN3iIA"
      ),
     ));
    
    $response = curl_exec($curl);
    $data = json_decode($response, true);
    
    echo $data;
    
    ?>
    

提交回复
热议问题