function display_tencent($args = '') { $default = array('username' => 'Weibo_ID', 'number' => '5', 'time' => '3600'); $r = wp_parse_args($args, $default); extract($r); $path = dirname(dirname(__FILE__)) . '/wordpress-tencent-microblog/xxx'; $cache = new SimpleCache(); $cache->cache_path = $path; $cache->cache_time = 43200; date_default_timezone_set('PRC'); if ($data = $cache->get_cache(date('Y-m-d-H'))) { $list = json_decode($data); } else { $uinfo = OpenSDK_Tencent_Weibo::call('statuses/broadcast_timeline', array('reqnum' => $number, 'type' => '1', 'contenttype' => '0')); $cache->set_cache(date('Y-m-d-H'), json_encode($uinfo)); } $decodedArray = $list; echo '<ul style="list-style-type:none;">'; foreach ($decodedArray['data']['info'] as $value) { echo '<li><div class="microblog"><a href="http://t.qq.com/' . $value['nick'] . '" rel="external nofollow" title="来自 腾讯微博" target="_blank" style="padding-right:3px;"><img class="microblog-ico" alt="腾讯微博" src="' . WP_PLUGIN_URL . '/wordpress-tencent-microblog/txwb.png" /></a><span class="microblog-content">' . str_replace(' ', ' ', $value['origtext']) . '</span> <span class="microblog-from" style="font-size:smaller;">-' . date("Y/m/d", $value['timestamp']) . ' 来自 ' . $value['from'] . '-</span></div></li>'; } echo '</ul>'; }