本文實例講述了redis+php實現微博列表功能。分享給大家供大家參考,具體如下:
個人主頁顯示微博列表(自己及關注人的微博列表)
/*獲取最新的50微博信息列表,列出自己發布的微博及我關注用戶的微博
*1.根據推送的信息獲取postid
*2.根據postid獲取發送的信息
*/
$r->ltrim("recivepost:".$user['userid'],0,49);
$postid_arr = $r->sort("recivepost:".$user['userid'],array('sort'=>'desc'));
if($postid_arr){
foreach($postid_arr as $postid){
$p = $r->hmget("post:postid:".$postid,array('userid','username','time','content'));
$weiboList .= 'div class="post">a class="username" href="profile.php?u='.$p['username'].'" rel="external nofollow" rel="external nofollow" >'.$p['username'].'/a>'.$p['content'].'br>i>'.formattime($p['time']).'前發布/i>/div>';
}
echo $weiboList;
}else{
echo 'div class="post" >這個家伙很懶,還未發布消息哦~/div>';
}
顯示個人微博列表
/**
*1.獲取個人發布微博的id的隊列
*2.根據postid獲取微博信息
**/
$r->ltrim("userpostid:".$prouid,0,49);
$postid_arr = $r->sort("userpostid:".$prouid,array('sort'=>'desc'));
if($postid_arr){
foreach($postid_arr as $postid){
$p = $r->hmget("post:postid:".$postid,array('userid','username','time','content'));
$weiboList .= 'div class="post">a class="username" href="profile.php?u='.$p['username'].'" rel="external nofollow" rel="external nofollow" >'.$p['username'].'/a>'.$p['content'].'br>i>'.formattime($p['time']).'前發布/i>/div>';
}
echo $weiboList;
}else{
echo 'div class="post" >這個家伙很懶,還未發布消息哦~/div>';
}
更多關于PHP相關內容感興趣的讀者可查看本站專題:《php+redis數據庫程序設計技巧總結》、《php面向對象程序設計入門教程》、《PHP基本語法入門教程》、《PHP數組(Array)操作技巧大全》、《php字符串(string)用法總結》、《php+mysql數據庫操作入門教程》及《php常見數據庫操作技巧匯總》
希望本文所述對大家PHP程序設計有所幫助。
您可能感興趣的文章:- PHP實現發送微博消息功能完整示例
- redis+php實現微博(二)發布與關注功能詳解
- redis+php實現微博(一)注冊與登錄功能詳解
- PHP+redis實現微博的拉模型案例詳解
- PHP+redis實現微博的推模型案例分析
- vue+php實現的微博留言功能示例
- php微信分享到朋友圈、QQ、朋友、微博
- PHP調用微博接口實現微博登錄的方法示例
- php新浪微博登錄接口用法實例
- 基于PHP實現發微博動態代碼實例