PHP code example of code-lives / im

1. Go to this page and download the library: Download code-lives/im library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

code-lives / im example snippets


im_id      Im 申请的id

im_key     Im 申请的key

admin_id   Im 管理员账号【选填】用于发送一些消息。比如 A和B在聊天  拿着A账号给B发送一条消息 或者 创建群组 查询群组等



$Im = new Im\api\Im($im_id,$im_key);

$Im->genUserSig($uid);



$Im = new Im\api\Im($im_id,$im_key,$admin_id);

$Im->account_import($uid,$nickname,$images); //用户的uid 姓名 头像

返回类型 true  false



$Im = new Im\api\Im($im_id,$im_key,$admin_id);

$Im->set_info($uid,$data); //用户的uid 用户字段配置

返回类型 true  false



$Im = new Im\api\Im($im_id,$im_key,$admin_id);

$Im->check_bind($uid); //用户uid

返回类型 true  false



$Im = new Im\api\Im($im_id,$im_key,$admin_id);

$Im->from_to($from_id,$to_id,$content);  //发送人id 接收人id 内容自定义的数组或字符串

返回类型 true  false



$Im = new Im\api\Im($im_id,$im_key,$admin_id);

$Im->msg_read($from_id,$to_id);  //发送人id 接收人id 内容自定义的数组或字符串

返回类型 true  false



$Im = new Im\api\Im($im_id,$im_key,$admin_id);

$Im->get_work_list($work_name,$offset,$limit);  //群名称  offset 类似于分页 limit 每页几条

返回类型 array()  false



$Im = new Im\api\Im($im_id,$im_key,$admin_id);

$Im->add_work($work_name,$uid);  //群名称  用户uid

返回类型 true  false



$Im = new Im\api\Im($im_id,$im_key,$admin_id);

$Im->create_work($create_id,$group_name);  //创建人id  群名称

返回类型 群id  false



$Im = new Im\api\Im($im_id,$im_key,$admin_id);

$Im->msg_read($from_id,$to_id);  //fromy_id 操作用户  to_id 被读用户

返回类型 群id  false



$Im = new Im\api\Im($im_id,$im_key,$admin_id);

$Im->get_history($parm);  //$parm['ChatType']消息类型 $parm['MsgTime'] 时间戳 2021010221=2021年10月1日21时-21时59分记录

返回类型 群id  false