PHP code example of newngapi / ngapi

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

    

newngapi / ngapi example snippets


use Newngapi\Ngapi\Client;

// Initialize the client
$client = new Client(
    'https://api.example.com', // Base URL
    'your_sn',                // SN from NG platform
    'your_secret_key'        // Secret key from NG platform
);

// Create a player
$result = $client->createPlayer('ag', 'player123', 'CNY');

// Get player balance
$balance = $client->getBalance('ag', 'player123', 'CNY');

// Get game URL
$gameUrl = $client->getGameUrl(
    'ag',
    'player123',
    '1',  // gameType: 1=视讯, 2=老虎机, 3=彩票, 4=体育, 5=电竞, 6=捕鱼, 7=棋牌
    'CNY',
    'device1'  // device1=电脑网页版, device2=手机网页版
);

// Transfer funds
$transfer = $client->transfer(
    'ag',
    'player123',
    'CNY',
    '100.00',
    '1',  // 1=转入, 2=转出
    'order1234567890123456'  // Optional order ID
);

[
    'code' => 10001,  // Error code
    'msg' => 'Error message',
    'data' => null
]