<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-cn" lang="zh-cn" dir="ltr"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> <?php include_once 'config.php'; include_once 'weibooauth.php'; $o = new WeiboOAuth(WB_AKEY, WB_SKEY, LAST_OAUTH_TOKEN, LAST_OAUTH_TOKEN_SECRET); $content = $o->get(sprintf("http://api.t.sina.com.cn/emotions.json"), array('source' => '3150341378')); //var_dump($content); echo "<b>The following is the emotions:</b>" . "<br/>"; foreach ($content as $c) { //var_dump($c); echo $c['phrase'] . ", " . $c['type'] . ", " . ($c['is_common'] ? 'common' : '!'); echo '<img src="' . $c['url'] . '" border=0/>'; echo "<br/>"; /* echo $c['name']; $img_url = $c['profile_image_url']; echo '<img src="' . $img_url . '" border=0/>'; $img_url = str_replace("/50/", "/180/", $img_url); echo '<img src="' . $img_url . '" border=0/>'; echo "<br/>"; */ } ?> </body> </html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-cn" lang="zh-cn" dir="ltr"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> <?php include_once 'config.php'; include_once 'weibooauth.php'; $c = new WeiboClient(WB_AKEY, WB_SKEY, LAST_OAUTH_TOKEN, LAST_OAUTH_TOKEN_SECRET); $uinfo = $c->show_user('2253016840'); echo print_r($uinfo, true); echo "\n<br/><br/>\n"; $o = new WeiboOAuth(WB_AKEY, WB_SKEY, LAST_OAUTH_TOKEN, LAST_OAUTH_TOKEN_SECRET); $content = $o->get(sprintf("http://api.t.sina.com.cn/users/hot.json"), array('source' => WB_AKEY)); //var_dump($content); echo "<b>The following is the hottest ones:</b>" . "<br/>"; foreach ($content as $c) { echo $c['name']; $img_url = $c['profile_image_url']; echo '<img src="' . $img_url . '" border=0/>'; $img_url = str_replace("/50/", "/180/", $img_url); echo '<img src="' . $img_url . '" border=0/>'; echo "<br/>"; } ?> </body> </html>
<?php /* * use the API "users/hot" to get users' informations from SINA and put * them into local DB. if there are any repeatedly informations with * the same uid, which is in local DB and from "users/hot", then refresh * the ones in local DB. */ include_once 'config.php'; include_once 'weibooauth.php'; include_once dirname(__FILE__) . '/../zmysqlConn.class.php'; include_once "expkits.inc.php"; $o = new WeiboOAuth(WB_AKEY, WB_SKEY, LAST_OAUTH_TOKEN, LAST_OAUTH_TOKEN_SECRET); $zconn = new zmysqlConn(); $hots = $o->get("http://api.t.sina.com.cn/users/hot.json", array('source' => WB_AKEY)); $sex = array('f', 'm'); if ($argc == 2) { if (in_array($argv[1] . '', $sex)) { $sex = array($argv[1]); } } $i = 0; foreach ($hots as $hot) { if (in_array('' . $hot['gender'], $sex) && intval($hot['id']) >= 0) { $sql = __get_user_insert_update_sql($hot); mysql_query("set names 'utf8';"); mysql_query($sql, $zconn->dblink) or die("~failed~~db_err:" . mysql_error() . "~~failed~"); $i += mysql_affected_rows(); } } echo "Total: " . count($hots) . " / Affected: " . $i . ". (" . date("Y-m-d H:i:s") . ")\n";