1. Connection Diagram

Retreive Gamota user info (userID and access token) from client then post to your server to verify, get character and create your character based on Gamota user id.

Mô hình kết nối

2. API user/info

  • Use this API to verify token on your server
  • URL: https://api.gamota.com/game/get_user_info?access_token=USER_ACCESS_TOKEN
  • Protocol: GET
  • Response Format: JSON
    • status: Boolean (true: query successful, false: query failed)
    • error_code: Integer (query error code)
      • error_code = 0: Successful.
      • error_code = 1: Some parameters are invalid.
      • error_code = 99: System is not available at the moment.
    • data: Object (returned data detail)
      • data.username: String (Username on system)
      • data.user_id: Integer (User's ID on system)
      • data.email: String (User's email on system)
      • data.phone: String (User's phone number on system)

3. Sample PHP code

function call_curl_get($url,$data_array){
    $data = '';
    if ($data_array != null) {
        foreach($data_array as $key=>$value) { $data .= $key.'='.$value.'&'; }
        rtrim($data,'&');        
    }    

    $ch = curl_init($url);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
    curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
    $info = curl_exec($ch);    
    curl_close($ch);    
    return json_decode($info, true);
}

// Verify user with Appota User API
function verify_appota_user($appota_access_token, $appota_userid) {
    $url = sprintf('https://api.gamota.com/game/get_user_info?access_token=%s', $appota_access_token);
    $data = call_curl_get($url, null);
    if(!$data['status'])
        return false;
    else {
        if($data["data"]["user_id"] == $appota_userid)
            return true;
        else
            return false;
    }    
}