PHP code example of mucts / sobot

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

    

mucts / sobot example snippets



use MuCTS\Sobot\Sobot;
// 获取访问Token
$token = (new Sobot(['app_id'=>'','app_key'=>'']))->token()->getToken();

use MuCTS\Sobot\Sobot;
use MuCTS\Sobot\Contracts\Cache as CacheInterface;

class Cache implements CacheInterface{
    public function set(string $key, $value, $tts): bool
    {
        // TODO 需要实现
    }
    public function get(string $key)
    {
        // TODO 需要实现
    }
    public function exists(string $key): bool
    {
        // TODO 需要实现
    }
}

// 获取访问Token
$token = (new Sobot(['app_id'=>'','app_key'=>''], new Cache()))->token()->getToken();


use MuCTS\Sobot\Sobot;
/** @var \MuCTS\Sobot\OnlineService\QueryAgent\Response $res */
$res = (new Sobot(['app_id'=>'','app_key'=>'']))
->onlineService()
->queryAgent()
->request();