我正在使用Github PHP Library。您可以使用Buzz HTTP 客户端进行特定调用,如下所示:
$client->getHttpClient()->get('repos/:user/:repo/events');
问题是该请求的返回是我不确定如何访问元素的东西:
Github\HttpClient\Message\Response Object
(
[remainingCalls] =>
[protocolVersion:Buzz\Message\Response:private] => 0
[statusCode:Buzz\Message\Response:private] => 200
[reasonPhrase:Buzz\Message\Response:private] => OK
[headers:Buzz\Message\AbstractMessage:private] =>
[content:Buzz\Message\AbstractMessage:private] =>
)
现在我可以循环遍历对象,执行如下操作:
foreach( $events as $item ) {
print_r( $item );
}
但我真的只关心里面的内容headers
和content
里面的内容。
有谁知道我如何直接访问这些元素而无需循环?