我正在尝试获取在 Twitter 上搜索某个词的用户列表,但到目前为止没有运气。这是我的代码:
$parameters = array('q' => '#puppy', 'count' => 2);
$results = $connection->get('search/tweets', $parameters);
//print_r($result);
foreach ($results as $data) {
?>
<div id="update">
<div id="left"><a href="https://twitter.com/#!/<?php echo $data->user->screen_name; ?>" target="_blank"/><img width="48px" height="48px" src="<?php echo $data->user->profile_image_url; ?>"/></a></div>
<div id="right">
<div class="user"><a href="https://twitter.com/#!/<?php echo $data->user->screen_name; ?>" target="_blank"/><?php echo $data->user->screen_name; ?></a> <?php echo $data->user->name; ?></div>
<div class="detail">
<?php echo $data->text; ?>
</div>
</div>
</div>
<?php
}
这就是它的输出:
Notice: Undefined property: stdClass::$user in line 150
Trying to get property of non-object in line 150
我知道我正在以一种奇怪的方式访问该数组,我只是无法弄清楚它需要如何。