一、调用方式
$this->load->model('sns_model'); //引用时需要加载sns模型类,只加载一次即可
$this->sns_model->following($ta_uid, $my_uid);二、参数值
| 参数 | 介绍 |
|---|---|
| $ta_uid | 关注Ta的uid |
$my_uid | 我的Uid |
三、返回值
0 关注失败
1 关注成功
2 相互关注
-1 取消关注
四、开发示例
1、通过类方法的方式来关注
//
....
public function guanzhu($ta_uid, $my_uid) {
$this->load->model('sns_model');
$rt = $this->sns_model->following($ta_uid, $my_uid);
if ($rt == 1) {
return '关注成功';
} elseif ($rt == 2) {
return '相互关注';
} elseif ($rt == -1) {
return '取消关注';
} else {
return '关注失败';
}
}
......2、通过url方式来关注
创建文件/member/controllers/guanzhu.php
class Guanzhu extends M_Controller {
public function __construct() {
parent::__construct();
}
public function index() {
$ta_uid = $this->input->get('uid');
if (!$this->uid) {
$this->member_msg('您尚未登录,无法关注对方');
}
$this->load->model('sns_model');
$rt = $this->sns_model->following($ta_uid, $this->uid);
if ($rt == 1) {
$this->member_msg('关注成功', '', 1);
} elseif ($rt == 2) {
$this->member_msg('相互关注', '', 1);
} elseif ($rt == -1) {
$this->member_msg('取消关注', '', 1);
} else {
$this->member_msg('关注失败');
}
}
}关注链接为:{MEMBER_URL}index.php?c=guanzhu&uid={关注对象的uid}
文档最后更新时间:2014-12-28 15:13:12