PHP code example of nece001 / php-sdk-coze

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

    

nece001 / php-sdk-coze example snippets


use Nece\Sdk\Coze\Client;

$client_id = '应用列表中的:应用 ID';
$client_secret = '创建key后生成的:公钥指纹';
$private_key = '创建key后下载的:私钥内容';

$client = new Client($client_id, $client_secret, $private_key);

// 设置 PSR-3 日志记录器
$client->setLogger($logger);
// 设置 PSR-16 缓存器
$client->setCacher($cache);

$accessToken = $client->getAccessToken()->getAccessToken();

$audioApi = $client->audio();
// 具体方法请参考 Audio 类文档

$conversationApi = $client->conversation();
$data = $conversationApi->conversations('会话ID');
bash
composer