PHP code example of nexconnai-dev / nexconn-server-sdk-php

1. Go to this page and download the library: Download nexconnai-dev/nexconn-server-sdk-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/ */

    

nexconnai-dev / nexconn-server-sdk-php example snippets



fig = NexConnServerSdkPhp\Configuration::getDefaultConfiguration()
    ->setNexconnCredentials('YOUR_APP_KEY', 'YOUR_APP_SECRET')
    ->setPrimaryBackupDomains(
        getenv('NEXCONN_PRIMARY_API_DOMAIN'),
        getenv('NEXCONN_SECONDARY_API_DOMAIN')
    );

// Optional runtime overrides:
// $config->setNonceGenerator(fn () => 'custom-nonce');
// $config->setErrorSwitchingThreshold(1);
// $config->setAutoFailoverEnabled(true);

$apiInstance = new NexConnServerSdkPhp\Api\UserManagementApi(
    new GuzzleHttp\Client(),
    $config
);
$request = new NexConnServerSdkPhp\Model\AccessTokenIssueRequest();
$request->setUserId('user_123');
$request->setName('Alice');
$request->setAvatarUrl('https://example.com/avatar.png');

try {
    $result = $apiInstance->issueAccessToken($request);
    print_r($result);
} catch (\NexConnServerSdkPhp\ApiException $e) {
    echo 'API error: errorCode=' . $e->getErrorCode() . ', errorMessage=' . $e->getErrorMessage() . PHP_EOL;
}

use NexConnServerSdkPhp\ApiException;
use NexConnServerSdkPhp\BadRequestException;
use NexConnServerSdkPhp\UnauthorizedException;
use NexConnServerSdkPhp\ForbiddenException;
use NexConnServerSdkPhp\NotFoundException;
use NexConnServerSdkPhp\ConflictException;
use NexConnServerSdkPhp\TooManyRequestsException;
use NexConnServerSdkPhp\ServiceException;

try {
    $result = $apiInstance->createGroup($request);
} catch (BadRequestException $e) {
    // HTTP 400 — invalid parameters
    echo 'Bad request: ' . $e->getErrorCode() . ' ' . $e->getErrorMessage() . PHP_EOL;
} catch (UnauthorizedException $e) {
    // HTTP 401 — check your AppKey / AppSecret
} catch (ForbiddenException $e) {
    // HTTP 403 — permission denied
} catch (NotFoundException $e) {
    // HTTP 404 — resource not found
} catch (ConflictException $e) {
    // HTTP 409 — resource already exists
    echo 'Conflict: errorCode=' . $e->getErrorCode() . PHP_EOL;
} catch (TooManyRequestsException $e) {
    // HTTP 429 — rate limited, retry later
} catch (ServiceException $e) {
    // HTTP 5xx — server error, may retry
} catch (ApiException $e) {
    // Other HTTP errors
    echo 'HTTP ' . $e->getCode() . ': ' . $e->getResponseBody() . PHP_EOL;
}
bash
composer config repositories.nexconn-sdk-php vcs https://github.com/NexconnAI-Dev/nexconn-server-sdk-php.git
composer 
bash
composer