PHP code example of maniac / easemob-php

1. Go to this page and download the library: Download maniac/easemob-php 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/ */

    

maniac / easemob-php example snippets




use Easemob\Auth;
use Easemob\User;

$auth = new Auth("appKey", "Client ID", "ClientSecret");
$user = new User($auth);



use Easemob\Auth;
use Easemob\User;

$auth = new Auth("appKey", "Client ID", "ClientSecret");
$user = new User($auth);

// 注册单个用户
$data = array(
    'username' => 'user1',
    'password' => 'user1',
    'nickname' => 'user1',
);
$user->create($data);

 
// 批量注册用户
$data = array(
    array(
        'username' => 'user2',
        'password' => 'user2',
        'nickname' => 'user2',
    ),
    array(
        'username' => 'user3',
        'password' => 'user3',
        'nickname' => 'user3',
    ),
);
$user->create($data);

header("Content-Type:text/html;charset=utf-8");



use Easemob\Auth;
use Easemob\Http\Http

$easemob = $config['easemob'];
$auth = new Auth("appKey", "Client ID", "ClientSecret");
// 设置代理
Http::setProxy("ip地址", 8080);

composer