Example #1
0
 public function getUserInfo($login_oauth, $oauth_verifier)
 {
     global $_FANWE;
     $oauth = new WeiboOAuth($this->config['app_key'], $this->config['app_secret'], $login_oauth['oauth_token'], $login_oauth['oauth_token_secret']);
     $last_key = $oauth->getAccessToken($oauth_verifier);
     $uid = $last_key['user_id'];
     $client = new WeiboClient($this->config['app_key'], $this->config['app_secret'], $last_key['oauth_token'], $last_key['oauth_token_secret']);
     $result = $client->show_user($uid);
     if ($result === false || $result === null) {
         exit("Error occured");
     }
     if (isset($result['error_code']) && isset($result['error'])) {
         exit('Error_code: ' . $result['error_code'] . ';  Error: ' . $result['error']);
     }
     $result['last_key'] = $last_key;
     return $result;
 }
Example #2
0
<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>
Example #3
0
<?php

/*
 * use the API "users/show" to get user's information from SINA and put
 * them into local DB. if there are any repeatedly informations with
 * the same uid, just overwrite it.   
 */
include_once 'config.php';
include_once 'weibooauth.php';
include_once dirname(__FILE__) . '/../zmysqlConn.class.php';
include_once "expkits.inc.php";
$c = new WeiboClient(WB_AKEY, WB_SKEY, LAST_OAUTH_TOKEN, LAST_OAUTH_TOKEN_SECRET);
$zconn = new zmysqlConn();
if ($argc != 2) {
    exit("it should take 1 parameter as 'uid'.\n");
}
$uid = $argv[1];
$user = $c->show_user($uid);
//var_dump($user);
if (array_key_exists("error", $user)) {
    echo $user['error'] . "#{$uid}#\n" . print_r($user, true);
} else {
    $sql = __get_user_insert_update_sql($user);
    mysql_query("set names 'utf8';");
    mysql_query($sql, $zconn->dblink) or die("~failed~~db_err:" . mysql_error() . "~~failed~\n");
    echo mysql_affected_rows() . " row affected.\n";
}
Example #4
0
<?php

session_start();
include_once 'config.php';
include_once 'weibooauth.php';
$c = new WeiboClient(WB_AKEY, WB_SKEY, $_SESSION['last_key']['oauth_token'], $_SESSION['last_key']['oauth_token_secret']);
//获得用户信息
$userid = $_SESSION['last_key']['user_id'];
$arr = $c->show_user($userid);
$username = $arr['name'];
//用户名
$usertou = $arr['profile_image_url'];
//用户头像地址
//=============
$im = imagecreatefromjpeg("by.jpg");
$tou = imagecreatefromjpeg($usertou);
$color = imagecolorallocate($im, 0, 0, 255);
imagettftext($im, 12, 0, 270, 122, $color, "simhei.ttf", $username);
imagettftext($im, 10, 0, 90, 220, $color, "simhei.ttf", "NO." . time());
imagecopy($im, $tou, 121, 131, 0, 0, 50, 50);
imagejpeg($im, $userid . ".jpg");
//=============
$t = "999999999999 http://www.php100.com";
$p = "http://localhost/sina12/" . $userid . ".jpg";
if (!empty($_POST['sub'])) {
    //$t 文字内容
    //$p 我们上传的图片路径
    $c->upload($t, $p);
}
?>
<img src="<?php