婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > redis+php實現(xiàn)微博(二)發(fā)布與關注功能詳解

redis+php實現(xiàn)微博(二)發(fā)布與關注功能詳解

熱門標簽:智能電話機器人好公司門薩維 聊城電話外呼系統(tǒng)公司 德陽中江如何申請400開頭電話 AI電話機器人OEM貼牌 沛縣400電話辦理 江蘇電商外呼系統(tǒng)運營商 青白江地圖標注 銅川電話機器人價格 辦理重慶400電話

本文實例講述了redis+php實現(xiàn)微博發(fā)布與關注功能。分享給大家供大家參考,具體如下:

數(shù)據(jù)結構:

set post:postid:3:time timestamp
set post:postid:3:userid 5
set post:postid:3:content 測試發(fā)布哈哈哈哈

incr global:postid
set post:postid:$postidcho "用戶名密碼不能夠為空!";

關注微博

following:3

被關注(粉絲)

followed:3

把發(fā)布的微博推給自己的粉絲

recivepost:10 postid

微博的發(fā)布代碼:

include("function.php");
include("header.php");
$content = I('content');
if(!$content){
  error('內(nèi)容不能夠為空');
}
$user = isLogin();
if($user==false){
  header("location:index.php");
  exit();
}
$r = redis_connect();
$postid = $r->incr('global:postid');
//$r->set("post:postid:".$postid.":time",time());
//$r->set("post:postid:".$postid.":userid",$user['userid']);
//$r->set("post:postid:".$postid.":content",$content);
$r->hmset("post:postid:".$postid,array('userid'=>$user['userid'],'username'=>$user['username'],'time'=>time(),'content'=>$content));
//把微博推給自己的粉絲
$fans = $r->smembers("followed:".$user['userid']);
$fans[] = $user['userid'];
foreach($fans as $fansid){
  $r->lpush('recivepost:'.$fansid,$postid);
}
//單獨累計個人發(fā)布的信息
$r->lpush('userpostid:'.$user['userid'],$postid);
header("location:home.php");
exit;
include("bottom.php");

微博的關注代碼:

include("function.php");
include("header.php");
if(isLogin()==false){
  header("location:index.php");
  exit;
}
$user = isLogin();
$uid = trim($_GET['uid']);
$f = trim($_GET['f']);
$r = redis_connect();
if($f==0){
  //將關注與被關注的數(shù)據(jù)結構存入redis
  $r->sadd("following:".$user['userid'],$uid);
  $r->sadd("followed:".$uid,$user['userid']);
}else{ 
  //取消關注
  $r->srem("following:".$user['userid'],$uid);
  $r->srem("followed:".$uid,$user['userid']);
}
//根據(jù)傳遞過來的userid查找username
$uname = $r->get("user:userid:".$uid.":username");
header("location:profile.php?u=".$uname);
include("bottom.php");

更多關于PHP相關內(nèi)容感興趣的讀者可查看本站專題:《php+redis數(shù)據(jù)庫程序設計技巧總結》、《php面向對象程序設計入門教程》、《PHP基本語法入門教程》、《PHP數(shù)組(Array)操作技巧大全》、《php字符串(string)用法總結》、《php+mysql數(shù)據(jù)庫操作入門教程》及《php常見數(shù)據(jù)庫操作技巧匯總》

希望本文所述對大家PHP程序設計有所幫助。

您可能感興趣的文章:
  • PHP實現(xiàn)發(fā)送微博消息功能完整示例
  • redis+php實現(xiàn)微博(三)微博列表功能詳解
  • redis+php實現(xiàn)微博(一)注冊與登錄功能詳解
  • PHP+redis實現(xiàn)微博的拉模型案例詳解
  • PHP+redis實現(xiàn)微博的推模型案例分析
  • vue+php實現(xiàn)的微博留言功能示例
  • php微信分享到朋友圈、QQ、朋友、微博
  • PHP調(diào)用微博接口實現(xiàn)微博登錄的方法示例
  • php新浪微博登錄接口用法實例
  • 基于PHP實現(xiàn)發(fā)微博動態(tài)代碼實例

標簽:烏魯木齊 山南 南寧 迪慶 濟寧 三亞 赤峰 鷹潭

巨人網(wǎng)絡通訊聲明:本文標題《redis+php實現(xiàn)微博(二)發(fā)布與關注功能詳解》,本文關鍵詞  redis+php,實現(xiàn),微博,二,發(fā)布,;如發(fā)現(xiàn)本文內(nèi)容存在版權問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《redis+php實現(xiàn)微博(二)發(fā)布與關注功能詳解》相關的同類信息!
  • 本頁收集關于redis+php實現(xiàn)微博(二)發(fā)布與關注功能詳解的相關信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 谷城县| 宣城市| 龙岩市| 新龙县| 怀安县| 泗水县| 桐庐县| 邛崃市| 阿拉善盟| 岚皋县| 长汀县| 巴林左旗| 台中市| 钟祥市| 灯塔市| 九寨沟县| 佛冈县| 梧州市| 阳信县| 富阳市| 龙山县| 宜都市| 临潭县| 丹凤县| 游戏| 泾阳县| 平邑县| 酒泉市| 阿鲁科尔沁旗| 合肥市| 定边县| 油尖旺区| 东海县| 安丘市| 广河县| 抚松县| 望谟县| 都兰县| 无锡市| 长治市| 平和县|