我的 twitter 插件不断收到此错误:
致命错误:不能使用 stdClass 类型的对象作为 C:.... 中的数组,第 72 行
它有时只显示,但是我的推特计数器在相当长的一段时间内都没有改变。请问你能帮忙吗?代码如下,关于行在中间: update_option('pyre_twitter_followers', $json[0]->user->followers_count);
<?php if(get_option('pyre_twitter_id')): ?>
<div class="social-box">
<a href='http://twitter.com/<?php echo get_option('pyre_twitter_id'); ?>'>
<img src="<?php echo get_template_directory_uri(); ?>/images/twitter.png" alt="Follow us on Twitter" width="48" height="48" /></a>
<?php
$interval = 3600;
if($_SERVER['REQUEST_TIME'] > get_option('pyre_twitter_cache_time')) {
@$api = wp_remote_get('http://twitter.com/statuses/user_timeline/' . get_option('pyre_twitter_id') . '.json');
@$json = json_decode($api['body']);
if(@$api['headers']['x-ratelimit-remaining'] >= 1) {
update_option('pyre_twitter_cache_time', $_SERVER['REQUEST_TIME'] + $interval);
update_option('pyre_twitter_followers', $json[0]->user->followers_count);
}
}
?>
<div class="social-box-text">
<span class="social-arrow"></span>
<span class="social-box-descrip"><?php _e('Follow us on Twitter', 'pyre'); ?></span>
<span class="social-box-count"><?php echo get_option('pyre_twitter_followers'); ?> <?php _e('Followers', 'pyre'); ?></span>
</div>
</div>
<?php endif; ?>