用户工具

站点工具


en:免转钱包phpdemo
phpDemo.php
<?php
date_default_timezone_set('PRC');
 
/**
* Free transfer wallet Merchant request platform PHP Demo
 * Class newngapi
 * @version (PHP 5 >= 5.3.0, PHP 7)
 * www.neapi.com
 */
class newngapi{
 
    protected  $api_account;
    protected  $sign_key;
 
protected $register_url; // Create a member account
protected $login_url; // Get the game login address
protected $trans_url; // quota conversion
protected $balance_url; // Inquiry on balance of free wallet (player's game platform + free wallet)
protected $balance_plat_type_url; // Member game platform balance query
protected $all_credit_url; // All platform balance query
protected $status_url; // Quota conversion status query
protected $collect_url; // Get game records
 
protected $plat_type; // Set platform type All lowercase
 
    public function __construct()
    {
        $this->plat_type = 'ag';
 
$this->api_account="API Account";
$this->sign_key = "API key";
 
$this->register_url = "http://域名/v1/user/register";
$this->login_url = "http://domain/v1/user/login";
$this->trans_url = 'http://domain/v1/wallet/trans';
$this->balance_url = 'http://domain/v1/wallet/balance';
$this->balance_plat_type_url = 'http://域名/v1/user/balance';
$this->status_url = 'http://domain/v1/wallet/status';
$this->all_credit_url= 'http://域名/v1/user/all-credit';
$this->collect_url = 'http://domain/v1/user/record';
    }
 
 
 
protected $game_type_live = '1'; //Live entertainment
protected $game_type_slot = '2'; //Slot machine
protected  $game_type_lottery = '3';  //彩票
protected  $game_type_sports = '4';   //体育
protected  $game_type_esports = '5';  //电竞
protected  $game_type_fishing = '6';  //捕鱼
protected  $game_type_poker = '7';    //棋牌
 
    /**
     * @param $username
     * @return mixed
* register
     */
    public function register($username){
        $code = md5($this->sign_key.$this->api_account.$this->plat_type.$username);
        $data = array(
            "username"=>$username,
            "plat_type"=>$this->plat_type,
            "sign_key"=>$this->sign_key,
            "code"=>$code
        );
        $res = $this->sendRequest($this->register_url, $data);
        return $res;
    }
 
    /**
     * @param $username
     * @param int $isMobileUrl
     * @param string $gameCode
     * @return mixed
* Get the login link
     */
    public function login($username,$isMobileUrl=0,$gameCode=""){
        $code = md5($this->sign_key.$this->api_account.$username.$this->plat_type.$isMobileUrl);
        $data = array(
            "username"=>$username,
            "plat_type"=>$this->plat_type,
            "game_type"=>$this->game_type_live,
            "game_code"=>$gameCode,
            "sign_key"=>$this->sign_key,
            "is_mobile_url"=>$isMobileUrl,
            "code"=>$code
        );
        $res = $this->sendRequest($this->login_url, $data);
        return $res;
    }
 
    /**
     * @param $username
     * @param $money
     * @param $client_transfer_id
     * @return mixed
* Update the center wallet amount
     */
    public function trans($username,$money,$client_transfer_id){
        $code = md5($this->sign_key.$this->api_account.$username.$money.$client_transfer_id);
        $data = array(
            "username"=>$username,
            "money"=>$money,
            "client_transfer_id"=>$client_transfer_id,
            "sign_key"=>$this->sign_key,
            "code"=>$code
        );
 
        $res = $this->sendRequest($this->trans_url, $data);
        return $res;
    }
 
 
    /**
     * @param $username
     * @param $client_transfer_id
     * @return mixed
* Check the update status of the center wallet
     */
    public function status($username,$client_transfer_id){
        $code = md5($this->sign_key.$this->api_account.$username.$client_transfer_id);
        $data = array(
            "username"=>$username,
            "client_transfer_id"=>$client_transfer_id,
            "sign_key"=>$this->sign_key,
            "code"=>$code
        );
        $res = $this->sendRequest($this->status_url, $data);
        return $res;
    }
 
    /**
     * @param $username
     * @return mixed
* Query the balance will return the balance of the player's current game and the center wallet.
     */
    public function balance($username){
        $code = md5($this->sign_key.$this->api_account.$username);
        $data = array(
            "username"=>$username,
            "sign_key"=>$this->sign_key,
            "code"=>$code
        );
        $res = $this->sendRequest($this->balance_url, $data);
        return $res;
    }
 
 
    /**
     * @param $username
     * @return mixed
* Return the player balance of a single game based on the game platform
     */
    public function platTypeBalance($username){
        $code = md5($this->sign_key.$this->api_account.$username.$this->plat_type);
        $data = array(
            "username"=>$username,
            "plat_type"=>$this->plat_type,
            "sign_key"=>$this->sign_key,
            "code"=>$code
        );
        $res = $this->sendRequest($this->balance_plat_type_url, $data);
        return $res;
    }
 
    /**
     * @return mixed
* Check the merchant platform quota
     */
    public function credit(){
        $code = md5($this->sign_key.$this->api_account);
        $data = array(
            "sign_key"=>$this->sign_key,
            "code"=>$code
        );
        $res = $this->sendRequest($this->all_credit_url, $data);
        return $res;
    }
 
    /**
     * @param $startTime
     * @param $endTime
     * @param int $page
     * @param int $limit
     * @return mixed
* Get game records
     */
    public function record($startTime,$endTime,$page=1,$limit=15){
        $code = md5($this->sign_key.$this->api_account.$this->plat_type.$startTime.$endTime);
        $data = array(
            "plat_type"=>$this->plat_type,
            "page"=>$page,
            "limit"=>$limit,
            "startTime"=>$startTime,
            "endTime"=>$endTime,
            "game_type"=>$this->game_type_slot,
            "sign_key"=>$this->sign_key,
            "code"=>$code
        );
        $res = $this->sendRequest($this->collect_url, $data);
        return $res;
    }
 
 
    private function sendRequest($url,$post_data=array()){
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
        $contents = curl_exec($ch);
        curl_close($ch);
        print_r($contents);die;
        return json_decode ($contents, TRUE);
    }
 
}
 
/**
* Use demo
 */
$api = new newngapi();
$res = $api->login("username");
print_r($res);
en/免转钱包phpdemo.txt · 最后更改: 2019/12/17 22:15 由 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki