Basic Commands
The SDK commands below are designed to conduct basic SDK operations:
Set API domainβ
Sets the SDK to use your back-end's domain name. Please head to https://app.vpnwholesaler.com/credentials in order to retrieve your API base domain name.
Important
Please use the domain name only without scheme (i.e. do not include https://)
Login required: No
CmdProc Code: OVS_CMD_SET_API_DOMAIN
Command number: 9
Input:
{
"api_domain": "your_subdomain.vpngn.com"
}
Response: OVS_NOTIFY_SET_API_DOMAIN
- Success
- Failure
OVS_ERR_OK
data is null
OVS_ERR_MISSING_PARAMS
data is null
Code sample:
- macOS
- Android
- Android (JSON)
void SetAPIDomain(const char *api_domain)
{
json_object *j_obj, *j_data_obj;
char szCmd[1024];
j_obj = json_object_new_object();
json_object_object_add(j_obj, "cmd", json_object_new_int(OVS_CMD_SET_API_DOMAIN));
j_data_obj = json_object_new_object();
json_object_object_add(j_data_obj, "api_domain", json_object_new_string(api_domain));
json_object_object_add(j_obj, "data", j_data_obj);
snprintf(szCmd, sizeof(szCmd), "%s", json_object_get_string(j_obj));
json_object_put(j_obj);
CmdProc(szCmd);
}
VPNSDK.CommandNotifyCB callback = new VPNSDK.CommandNotifyCB() {
@Override
public void onNotify(int notification, int error, Object data) {
if (error == VPNSDK.OVS_ERROR_CODES.OVS_ERR_OK) {
// Do something when command is successful
} else {
// Process error
}
}
};
VPNSDK.CmdProc(VPNSDK.OVS_CMD_CODES.OVS_CMD_SET_API_DOMAIN, callback, your_subdomain);
VPNSDK.CmdProc(β{\βcmd\β: 9, \βdata\β : { \βapi_domain\β : \βyour_subdomain.vpngn.com\β}}β);
Set Logger Modeβ
Enable or disable log file creation. Logging is disabled by default.
Login required: No
CmdProc Code: OVS_CMD_SET_LOGGING
Command number: 26
Input:
{
"status": true | false
}
Response: OVS_NOTIFY_SET_LOGGING
- Success
- Failure
OVS_ERR_OK
data is null
OVS_ERR_MISSING_PARAMS
data is null
Code sample:
- macOS
- Android
- Android (JSON)
void SetLogging(bool status)
{
json_object *j_obj, *j_data_obj;
char szCmd[1024];
j_obj = json_object_new_object();
json_object_object_add(j_obj, "cmd", json_object_new_int(OVS_CMD_SET_LOGGING));
j_data_obj = json_object_new_object();
json_object_object_add(j_data_obj, "status", json_object_new_boolean(status));
json_object_object_add(j_obj, "data", j_data_obj);
snprintf(szCmd, sizeof(szCmd), "%s", json_object_get_string(j_obj));
json_object_put(j_obj);
CmdProc(szCmd);
}
VPNSDK.CommandNotifyCB callback = new VPNSDK.CommandNotifyCB() {
@Override
public void onNotify(int notification, int error, Object data) {
if (error == VPNSDK.OVS_ERROR_CODES.OVS_ERR_OK) {
// Do something when command is successful
} else {
// Process error
}
}
};
VPNSDK.CmdProc(VPNSDK.OVS_CMD_CODES.OVS_CMD_SET_LOGGING, callback, "enable");
VPNSDK.CmdProc("{\"cmd\": 26, \"data\": {\"status\" : \"enable\" }}");
VPNSDK.CmdProc("{\"cmd\": 26, \"data\": {\"status\" : \"disable\" }}");
Loginβ
Logins to the back-end and retrieves active products associated with the given user.
Login required: No
CmdProc Code: OVS_CMD_LOGIN
Command number: 1
Input:
{
"username": "end_user_email_address",
"password": "end_user_password"
}
Username - End-user's username
Password - End-user's password
Response: OVS_NOTIFY_LOGIN
- Success
- Success Android and iOS
- Failure
OVS_ERR_OK
Data contains information about user account and account status:
nextduedate - Plan renewal date
username - OpenVPN username
password - OpenVPN password
status - Account status
name - User's first name
email - User's email address
debug - Debug mode?
free - Free plan?
OVS_ERR_OK
Data contains information about user account and account status:
nextduedate - Plan renewal date
debug - Debug mode?
long_token - Long authorisation token
last_name - Client's last name
clid - Client's email
password - VPN password
account_password - Password used for logging in
product_id - Product ID
company_name - Client's company name
name - Product name
last_product_change - Last product change time stamp
free - Free product?
first_name - Client's first name
email - Username used for logging in
username - VPN user name
status - Account status
expired_ts - Expiration time stamp
OVS_ERR_WEB_API
OVS_ERR_RESP_INVALID
OVS_ERR_LOGIN_FAILED
OVS_ERR_NO_ACTIVE_PLAN - after receiving this response it is still possible to use user management functions.
However, VPN functions are unavailable until the end-user is logged-in with an active plan (it is recommended to invoke Logout method before logging-in).
data contains a human readable error description
Code sample:
- macOS
- Android
- Android (JSON)
void Login(const char *username, const char *password)
{
json_object *j_obj, *j_data_obj;
char szCmd[1024];
j_obj = json_object_new_object();
json_object_object_add(j_obj, "cmd", json_object_new_int(OVS_CMD_LOGIN));
j_data_obj = json_object_new_object();
json_object_object_add(j_data_obj, "username", json_object_new_string(username));
json_object_object_add(j_data_obj, "password", json_object_new_string(password));
json_object_object_add(j_obj, "data", j_data_obj);
snprintf(szCmd, sizeof(szCmd), "%s", json_object_get_string(j_obj));
json_object_put(j_obj);
CmdProc(szCmd);
}
VPNSDK.CommandNotifyCB callback = new VPNSDK.CommandNotifyCB() {
@Override
public void onNotify(int notification, int error, Object data) {
if (error == VPNSDK.OVS_ERROR_CODES.OVS_ERR_OK) {
// Do something if login is successful
} else {
// Process error
}
}
};
VPNSDK.CmdProc(VPNSDK.OVS_CMD_CODES.OVS_CMD_LOGIN, callback, "username", "password")
VPNSDK.CmdProc("{\"cmd\" : 1, \"data\" : {\"username\": \"username\", \"password\": \"password\"}}");
Logoutβ
Logs out a currently logged-in end-user.
Login required: Yes
CmdProc Code: OVS_CMD_LOGOUT
Command number: 38
Input: Not required
Response: OVS_NOTIFY_LOGOUT
- Success
- Failure
OVS_ERR_OK
data is null
OVS_ERR_LOGOUT
data contains a human readable error description
Code sample:
- Windows
- macOS
void Logout()
{
json_object *j_obj;
char szCmd[1024];
j_obj = json_object_new_object();
json_object_object_add(j_obj, "cmd", json_object_new_int(OVS_CMD_LOGOUT));
snprintf(szCmd, sizeof(szCmd), "%s", json_object_get_string(j_obj));
json_object_put(j_obj);
CmdProc(szCmd);
}
void Logout()
{
json_object *j_obj, *j_data_obj;
char szCmd[1024];
j_obj = json_object_new_object();
json_object_object_add(j_obj, "cmd", json_object_new_int(OVS_CMD_LOGOUT));
snprintf(szCmd, sizeof(szCmd), "%s", json_object_get_string(j_obj));
json_object_put(j_obj);
CmdProc(szCmd);
}