user_timeline_by_id() public method

返回用户的发布的最近n条信息,和用户微博页面返回内容是一致的。此接口也可以请求其他用户的最新发表微博。
对应API:{@link http://open.weibo.com/wiki/2/statuses/user_timeline statuses/user_timeline}
public user_timeline_by_id ( mixed $uid = NULL, integer $page = 1, integer $count = 50, integer $since_id, integer $max_id, integer $feature, integer $trim_user, integer $base_app ) : array
$uid mixed 指定用户UID或微博昵称
$page integer 页码
$count integer 每次返回的最大记录数,最多返回200条,默认50。
$since_id integer 若指定此参数,则只返回ID比since_id大的微博消息(即比since_id发表时间晚的微博消息)。可选。
$max_id integer 若指定此参数,则返回ID小于或等于max_id的提到当前登录用户微博消息。可选。
$feature integer 过滤类型ID,0:全部、1:原创、2:图片、3:视频、4:音乐,默认为0。
$trim_user integer 返回值中user信息开关,0:返回完整的user信息、1:user字段仅返回uid,默认为0。
$base_app integer 是否基于当前应用来获取数据。1为限制本应用微博,0为不做限制。默认为0。
return array
Ejemplo n.º 1
0
 // sina_repost
 //$wid = strval(floatval($_POST['id']));
 $wid = substr($_POST['id'], 0, 16);
 var_dump($wid);
 // tmp debug
 var_dump($_POST['id']);
 $uid = $_SESSION['sid'];
 $page = 1;
 $count = 50;
 $since_id = 0;
 $max_id = 0;
 $base_app = 0;
 $trim_user = 0;
 $feature = 1;
 // 0-全部,1-原创,2-图片,3-视频,4-音乐
 $statuses = $c->user_timeline_by_id($uid, $page, $count, $since_id, $max_id, $feature, $trim_user, $base_app);
 if_weiboapi_fail($statuses);
 foreach ($statuses['statuses'] as $status) {
     if ("{$wid}" == $status['idstr']) {
         // wid 是当前用户的原创微博
         // 扣钱先
         $sql = "update user set realtime_money = realtime_money - {$db_total_price} where user_id = '{$_SESSION['uid']}' limit 1";
         $num = $dbo->exeUpdate($sql);
         if (1 != $num) {
             $msg = "扣钱失败,跳转。SQL:" . $sql;
             debug($msg, __FILE__, __LINE__);
         }
         // 扣钱成功,写task表
         $sql = "insert into task (owner_id, publisher_id, type, base_price, amount, status, create_at, expire_in) values('{$_SESSION['uid']}', '{$_SESSION['uid']}', 1, '{$db_base_price}', '{$amount}', 1, now(), '{$expire_in_sec}')";
         $num = $dbo->exeUpdate($sql);
         if (1 != $num) {
Ejemplo n.º 2
0
<?php

/**************************************************
	#  微博图床 V1 &copy;  lolimilk.com
	#  upsina.php  Created on 2013.08.06
	#	 Weibo: http://weibo.com/614520789
***************************************************/
header('Content-Type:text/html;charset=utf-8');
session_start();
include_once 'config.php';
include_once 'saetv2.ex.class.php';
$c = new SaeTClientV2(WB_AKEY, WB_SKEY, $_SESSION['token']['access_token']);
if (isset($_FILES['Filedata1']['tmp_name'])) {
    $weekarray = array("日", "一", "二", "三", "四", "五", "六");
    $msg1 = $c->upload("#SinaUploader#" . date("Y-m-d H:i:s") . "星期" . $weekarray[date("w")], $_FILES['Filedata1']['tmp_name']);
    $msg2 = $c->user_timeline_by_id($_SESSION['userinfo']['id'], 1, 1, 0, 0, 0, 1, 0);
    ?>


<?php 
    echo '<input type="text" readonly="readonly" onmouseover="this.select()" onfocus="this.select()" value="[img]' . $msg2['statuses']['0']['original_pic'] . '[/img]" style="width:340px;">';
    echo '<button class="thumbnail">预览<span><img src="' . $msg2['statuses']['0']['bmiddle_pic'] . '" width="50" border="0"></span>';
    echo "<br>";
    ?>

<?php 
}
Ejemplo n.º 3
0
// init $authURL
include_once $webRoot . "foundation/status.php";
if (!is_login()) {
    header('Location:' . $siteRoot . 'index.php?login_error=not_login');
}
require_once $webRoot . 'foundation/debug.php';
require_once $webRoot . 'foundation/page.php';
require_once $webRoot . 'foundation/price.php';
require_once $webRoot . 'lib/saetv2.ex.class.php';
global $sina_weibo_id_length;
// init in config.php
if (isset($_POST['weibo_id']) && is_numeric($_POST['weibo_id']) && $sina_weibo_id_length === strlen($_POST['weibo_id'])) {
    $real_wid = $_POST['weibo_id'];
    $stoken = $_SESSION['stoken'];
    $c = new SaeTClientV2(WB_AKEY, WB_SKEY, $stoken);
    $api_res = $c->user_timeline_by_id(NULL, 1, 50, 0, 0, 1, 1, 0);
    if_weiboapi_fail($api_res);
    $wids = $api_res['statuses'];
    $text = "";
    // 微博文本
    foreach ($wids as $wid) {
        if ($real_wid == $wid['id']) {
            $text = $wid['text'];
        }
    }
    if (empty($text)) {
        // 验证微博id未通过,说明post过来的id无效。
        echo '对不起,该条微博不是您的原创微博,请查证,若您。。';
        exit;
    }
    ?>
Ejemplo n.º 4
0
{
  $form_action .= '?'.$_SERVER['QUERY_STRING'];
}
 */
define('SHOW_PAGES', 5);
$rows_per_page = 50;
$total_rows = intval($user_message['statuses_count']);
$last_page = ceil($total_rows / $rows_per_page);
$page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 1;
if ($page < 1) {
    $page = 1;
}
if ($page > $last_page) {
    $page = $last_page;
}
$ms = $c->user_timeline_by_id($uid, $page);
?>
<!DOCTYPE html> 
<html> 
  <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>微博批量删</title> 
    <link rel="stylesheet" href="assets/css/bootstrap.min.css" />
    <link rel="stylesheet" href="assets/css/xweibo.css" />
    <script src="assets/js/jquery-1.7.1.min.js" type="text/javascript"></script>
  </head>

<body>
    <div class="navbar navbar-fixed-top">
      <div class="navbar-inner">
        <div class="container">
$sql_res = $dbo->getRs($sql);
$task_weibo_mids = array();
if (0 != count($sql_res)) {
    foreach ($sql_res as $weibo) {
        echo 'mid -- ' . $weibo['repost_mid'] . '-- ' . $weibo['task_text'] . '<br />';
        $task_weibo_mids[$weibo['task_id']] = $weibo['repost_mid'];
    }
} else {
    echo '<p>我最近没有在微动力上做任务</p>';
}
// 通过api查询当前用户最近转发的微博id
//var_dump($sql_res);
echo '<hr />';
$c = new SaeTClientV2(WB_AKEY, WB_SKEY, $_SESSION['stoken']);
echo '<h3>我最近通过微动力发布的微博id</h3>';
$repost_weibos = $c->user_timeline_by_id($_SESSION['sid'], 1, 200, 0, 0, 0, 0, 1);
// base_app == 1
//var_dump($repost_weibos);
if (!$repost_weibos || 0 == $repost_weibos['total_number']) {
    // 通过微动力转发的微博全都不在了
    echo '<p>我最近通过微动力发布的微博全都不在了</p>';
    $fail_tasks = $task_weibo_mids;
} else {
    foreach ($repost_weibos['statuses'] as $weibo) {
        echo $weibo['mid'] . ' -- ' . $weibo['text'] . ' <sub>on: ' . $weibo['created_at'] . '</sub><br />';
        $real_weibo_mids[] = $weibo['mid'];
    }
    $fail_tasks = array();
    $fail_tasks = array_diff($task_weibo_mids, $real_weibo_mids);
}
echo '<hr />';
Ejemplo n.º 6
0
 public function index()
 {
     $pattern = "/(http:\\/\\/tp[a-zA-Z0-9.\\/]+)/";
     //匹配网页中的微博头像链接
     $url = "http://data.weibo.com/top/influence/famous";
     //名人影响力排行榜官方主页
     $contents = file_get_contents($url);
     //抓取页面
     //如果出现中文乱码使用下面代码
     //$getcontent = iconv("gb2312", "utf-8","GBK",$contents);
     $temp = $this->session->userdata('access_token');
     //从session中获取access_token
     if (empty($temp)) {
         $o = new SaeTOAuthV2(WB_AKEY, WB_SKEY);
         $code_url = $o->getAuthorizeURL(WB_CALLBACK_URL);
         echo "<meta http-equiv=refresh content='0; url={$code_url}'>";
         //跳转到授权页面
     } else {
         $c = new SaeTClientV2(WB_AKEY, WB_SKEY, $temp);
         //向user_day中写数据之前先清空前一天的数据
         $this->db->query('truncate table user_day');
         //向weibo表中写数据之前先清空前一天的数据
         $this->db->query('truncate table weibo');
         if (preg_match_all($pattern, $contents, $matches, PREG_PATTERN_ORDER)) {
             for ($i = 0; $i < 20; $i++) {
                 $match = $matches[0][$i];
                 $res = explode("/", $match);
                 //以“/”为标志将头像链接分割
                 $uid = 1 + $res[3] - 1;
                 //$res[3]是字符串型的名人微博ID,此处将其处理为float型的$uid
                 $user_info = $c->show_user_by_id($uid);
                 //获取用户信息
                 //$weibo=$c->user_timeline_by_id(array('uid'=>$uid,'count'=>100));  //取100条微博
                 $weibo = $c->user_timeline_by_id($uid, 1, 100);
                 //向数据表user_day中写入数据
                 $this->celtop_model->set_user_day($uid, $user_info['screen_name'], $match);
                 //$match即为用户的头像链接
                 //向数据表weibo中写数据
                 $weibo_info = $weibo['statuses'];
                 foreach ($weibo_info as $item) {
                     $created_at = $item['created_at'];
                     $txt = $item['text'];
                     $weibo_mid = $this->midToStr($item['mid']);
                     //echo $weibo_mid;
                     $repost_count = $item['reposts_count'];
                     //转发量
                     $comment_count = $item['comments_count'];
                     //评论量
                     $sum_rep_comm = $repost_count + $comment_count;
                     //转发与评论数量之和
                     if (isset($item['retweeted_status'])) {
                         if (isset($item['retweeted_status']['user'])) {
                             $retweeted_uid = $item['retweeted_status']['user']['id'];
                             //原博主ID
                             $retweeted_screen_name = $item['retweeted_status']['user']['screen_name'];
                             //原博主昵称
                         } else {
                             $retweeted_uid = '';
                             $retweeted_screen_name = '';
                         }
                         $retweeted_txt = $item['retweeted_status']['text'];
                         //原微博内容
                     } else {
                         $retweeted_uid = '';
                         $retweeted_screen_name = '';
                         $retweeted_txt = '';
                     }
                     $this->celtop_model->set_weibo($uid, $created_at, $txt, $weibo_mid, $repost_count, $comment_count, $retweeted_uid, $retweeted_screen_name, $retweeted_txt, $sum_rep_comm);
                 }
                 //向数据表user_total中写入数据
                 $date_rank = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 1, date("Y")));
                 //当前显示的是前一天的名人影响力排行
                 $this->celtop_model->set_user_total($uid, $user_info['screen_name'], $match, $date_rank);
             }
         }
     }
     echo "DB has been updated!";
 }
Ejemplo n.º 7
0
      foreach($matches[0] as $match)   //取出50条微博头像链接进行处理
      {
          echo $match.'<br/>';
          $res=explode("/",$match);  //以“/”为标志将头像链接分割
          echo $res[3].'<br/>';
          //$uid=1+$res[3]-1;    //$res[3]是字符串型的名人微博ID,此处将其处理为float型的$uid
          //$uer_info=$c->show_user_by_id($uid);
      }
  }*/
$yesterday = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 2, date("Y")));
echo $yesterday . '<br/>';
var_dump($yesterday);
$a = "2725806687";
$b = 1 + $a - 1;
echo $b . '<br/>';
var_dump($b);
$uid = 1192329374;
$temp = $this->session->userdata('access_token');
$c = new SaeTClientV2(WB_AKEY, WB_SKEY, $temp);
$weibo = $c->user_timeline_by_id($uid);
foreach ($weibo['statuses'] as $item) {
    echo $item['id'] . '<br/>';
    if (isset($item['retweeted_status'])) {
        echo $item['retweeted_status']['user']['id'] . '<br/>';
        echo $item['retweeted_status']['user']['screen_name'] . '<br/>';
    }
}
?>
    <a target=:_blank' href="http://192.168.8.79/celebritytop/index.php/db_update" _target="blank"> 更新数据库</a>
</body>
        </html>
Ejemplo n.º 8
0
// 用户所在地,用户描述,性别,粉丝数,关注数,微博数,收藏数,是否认证,认证原因,注册时间
$user_info = $c->show_user_by_id($_SESSION['sid']);
if_weiboapi_fail($uesr_info);
$user['location'] = $user_info['location'];
$user['description'] = $user_info['description'];
$user['gender'] = $user_info['gender'];
$user['followers_count'] = $user_info['followers_count'];
$user['friends_count'] = $user_info['friends_count'];
$user['statuses_count'] = $user_info['statuses_count'];
$user['favourites_count'] = $user_info['favourites_count'];
$user['verified'] = $user_info['verified'];
$user['verified_reason'] = $user_info['verified_reason'];
$user['create_at'] = $user_info['created_at'];
// 原创微博数,优质粉丝列表,优质粉丝数,有效粉丝数
// 最新微博平均被转发次数/平均被评论次数 和 最高转发次数/评论次数
$weibos = $c->user_timeline_by_id($_SESSION['sid']);
if_weiboapi_fail($weibos);
$weibo_amount = count($weibos['statuses']);
unset($ids);
foreach ($weibos['statuses'] as $weibo) {
    $ids .= $weibo['id'] . ',';
    // 注意,如果系统字长不够,此处有可能无法处理这个数字型的id
    echo $weibo['id'] . '<br />';
}
$params = array();
$params['ids'] = $ids;
$weibo_counts = $c->oauth->get('statuses/count', $params);
if_weiboapi_fail($weibo_counts);
if (0 != $weibo_amount) {
    // 发过微博
    $max_reposts = 0;
Ejemplo n.º 9
0
                 echo  '</div>';
                }
         }
} 
*/
$f_byid = $c->friends_by_id($targetid, 0, 20);
//根据ID获取用户的关注列表
$sortsid = array();
$i = 0;
if (is_array($f_byid['users'])) {
    foreach ($f_byid['users'] as $item_u) {
        echo '<div style="padding:10px;margin:5px;border:1px solid #ccc">';
        echo '####################################<br>';
        echo $item_u['id'] . '<br>';
        echo $item_u['screen_name'] . ':<br>';
        $ut_byid = $c->user_timeline_by_id($item_u['id'], 1, 1);
        if (is_array($ut_byid['statuses'])) {
            foreach ($ut_byid['statuses'] as $item_c) {
                echo '############<br>';
                // echo 'i='.$i.'<br>';
                echo $item_c['text'] . '<br>';
                echo $item_c['created_at'] . '<br>';
                echo 'SID:' . $item_c['id'] . '<br>';
                $sortsid[$i] = $item_c['id'];
                // echo $sortsid[$i];
                $i++;
                /*
                    $gc_bysid = $c->get_comments_by_sid($item_c['id']);
                     			if( is_array( $gc_bysid['comments'] ) )
                			{
                   				foreach( $gc_bysid['comments'] as $item_a )  //读取每条微博的评论