环信核心包下载
http://pan.baidu.com/share/link?shareid=4139851189&uk=354467824
下载以后把放到TP框架的核心包下
下边是控制器实现的方法,只写了几个测试一下,更多方法可以看核心包
<?php
namespace Admin\Controller;
use Think\Controller;
use Think\Easemob;
class IndexController extends Controller {
public function index(){
echo "hello";
}
//注册用户
public function registerImUser($username,$password,$nickname){
$options['client_id'] = 'YXA6f3TaAJQUEeapCfugNq2yUQ';
$options['client_secret'] = 'YXA6tjEKAxWdE3LT8PY7oI_WRuUSevo';
$options['org_name'] = 'jinshengyuankeji';
$options['app_name'] = 'tututestforweb';
$e = new Easemob($options);
$result_u = $e->createUser($username,$password);
$result_n = $e->editNickname($username,$nickname);
return $result_n;
}
//添加好友
public function addFriends(){
$e = new Easemob($options);
$username = 'hututu';
$friend_name = 'weixin';
$e->addFriend($username,$friend_name);
}
//获取好友列表
public function getFriends(){
$e = new Easemob($options);
$username = 'hututu';
$result = $e->showFriends($username);
$this->ajaxReturn($result);
}
}