从API中提取标题

时间:2016-01-15 04:51:23

标签: php

好吧,所以我从一些简单的事情开始,只是为了让我熟悉到底是什么让自己陷入困境,如何修补我迷失了。

好的,所以我想从以下

获取内容
$details = json_decode(file_get_contents("https://beam.pro/api/v1/users/63662"));

我能做到这一点的最佳方式是什么?

目前,我可以使用print $details->username;显示用户名部分,使用id显示print $details->id;部分,但在此之后我会迷失方向,例如,我可以去拉标题。

这是Twitter目前在API中的样子 "name":"Thursday -- BR 2's [NA] w/ beam.pro/para",

Documentation is here

1 个答案:

答案 0 :(得分:1)

您将使用以下内容:

echo $details->channel->name;

但是,如果您对数组更满意,可以这样做:

$details = json_decode(file_get_contents("https://beam.pro/api/v1/users/63662"), true);
echo $details['channel']['name'];

以下是将来参考的对象结构:

enter image description here