[英]How to grab the username in the JSON Twitter V2 response using PHP?
I can grab "text" for example with the code below, but how can I grab the username "Lionek_Gaming" under includes > user?例如,我可以使用下面的代码获取“文本”,但是如何在包含 > 用户下获取用户名“Lionek_Gaming”?
$tweets = json_decode($response);
foreach($tweets->data as $tweet) {
$text = $tweet->text;
echo $text;
}
Json response Json 响应
{
"data": [
{
"author_id": "1169144412171055104",
"id": "1386731275160072192",
"text": "sell Bitcoin at sweet rates"
}
],
"includes": {
"users": [
{
"id": "1304731585112158209",
"name": "Lionek_official #BRG",
"username": "Lionek_Gaming"
}
]
},
}
Try the following:尝试以下操作:
foreach($tweets->includes->users as $user) {
$username = $user->username;
echo $username;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.