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;

// 初始化客户端
$client = new Client(
    'https://api.example.com', // 基础URL
    'your_sn',                // NG平台的SN
    'your_secret_key'        // NG平台的密钥
);

// 创建玩家
$result = $client->createPlayer('ag', 'player123', 'CNY');

// 获取玩家余额
$balance = $client->getBalance('ag', 'player123', 'CNY');

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

// 资金转账
$transfer = $client->transfer(
    'ag',
    'player123',
    'CNY',
    '100.00',
    '1',  // 1=转入, 2=转出
    'order1234567890123456'  // 可选的订单ID
);

[
    'code' => 10001,  // 错误代码
    'msg' => '错误信息',
    'data' => null
]