簡體   English   中英

如何從內容響應 Laravel 中獲取 access_token

[英]how to get access_token from content response laravel

我有來自 api 響應的響應內容:

{"token_type":"Bearer","expires_in":31535919,"access_token":"eyJ0eXa99e760ef4e468d17198f9fa6be9d67c36240a9bf9bb74d76b18e18ca2661706e33d1bc80cdAiOiJKV1QiLCJhbGciOiJSU.......

我如何獲得access_token值? 所以我可以使用它。

您可以使用json_decode函數將其轉換為對象並在那里訪問它。

$response = '{"token_type":"Bearer","expires_in":31535919,"access_token":"eyJ0eXa99e760ef4e468d17198f9fa6be9d67c36240a9bf9bb74d76b18e18ca2661706e33d1bc80cdAiOiJKV1QiLCJhbGciOiJSU.......';

$response = json_decode($response, true);
echo $response['access_token'];

希望這可以幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM