PHP code example of edoctor / ecs-phpsdk

1. Go to this page and download the library: Download edoctor/ecs-phpsdk 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/ */

    

edoctor / ecs-phpsdk example snippets


use Redis;
use eDoctor\Phpecs\Phpecs;
use eDoctor\Phpecs\Request\User\Login as UserLogin;

$redis = new Redis();
$redis->connect('127.0.0.1', '6379');

$config = [
    'api_server'    => '',
    'api_key'       => '',
    'api_secret'    => '',
    'request_timeout'   => 60
];
$phpecs = new Phpecs($config, $redis);

$userLogin = new UserLogin($phpecs);
$userLogin->setRoleId(1);
$userLogin->setAuthMethod('mobile');
$userLogin->setMobile('13300002222');
$userLogin->setPassword('123456');
$userLogin->setPlatform('android');

$response = $userLogin->getResponse();

eDoctor\Phpecs\PhpecsProvider::class,

class UserController extends Controller
{
    public function login(Request $request, Phpecs $phpecs)
    {
        $ecs = new Login($phpecs);
        $ecs->setRoleId(1);
        $ecs->setAuthMethod('mobile');
        $ecs->setMobile($request->input('mobile'));
        $ecs->setPassword($request->input('password'));
        $ecs->setPlatform('windows');
        $response = $ecs->getResponse();
        
        dd($response);
    }
}
shell
php artisan vendor:publish --provider="eDoctor\Phpecs\PhpecsProvider" --tag=config
ini
ECS_API_SERVER=
ECS_API_KEY=
ECS_API_SECRET=
ECS_REQUEST_TIMEOUT=60

当然也可以直接修改 config/phpecs.php (不推荐)