php jwt

[root@lnmp public]# cat jwt.php
<?php
$url = "http://192.168.2.131/api/auth/me";
$post_data = array ("username" => "bob","key" => "12345");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$accessToken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC8xOTIuMTY4LjIuMTMxXC9hcGlcL2F1dGhcL2xvZ2luIiwiaWF0IjoxNTQ3Nzk2NDU1LCJleHAiOjE1NDc4MDAwNTUsIm5iZiI6MTU0Nzc5NjQ1NSwianRpIjoiRnoySzZEZTU3T0JLYUQ2RyIsInN1YiI6MywicHJ2IjoiODdlMGFmMWVmOWZkMTU4MTJmZGVjOTcxNTNhMTRlMGIwNDc1NDZhYSJ9.bPfTBUmq9DaPooHuOyd-g0Rbq_OkSNRn758cSMR8HO4";
//$headers[]  =  "Accept:application/json";
$headers[]  =  "Authorization: Bearer ". $accessToken;
print_r($headers);
if( !empty($headers) ){
    curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
}
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$output = curl_exec($ch);
curl_close($ch);
//打印获得的数据
print_r($output);
[root@lnmp public]# 

    A+
发布日期:2019年01月18日  所属分类:未分类

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: