Verification(Last Updated : 07/06/2017)
Use POST Verification to verify the code sent to the recipient. This will verify the custom or system generated code.
You can check the code’s status via GET Authentication if you verify the code without POST Verification.
Methods
POST | /rest/v1/{user_name}/verification/sms/{auth_id} |
POST | /rest/v1/{user_name}/verification/voice/{auth_id} |
POST SMS Verification
Verify a code for the SMS authentication.
Resource Information
Response Formats | JSON |
Allowed Methods | POST |
URL | http://api.trumpia.com/rest/v1/{user_name}/verification/sms/{auth_id} |
{user_name} | Your account username (this can be found in the Account Settings page after logging in.) |
{auth_id} | The key for the specific authentication request. Example value: X0001 |
Header Parameters
* required parameters
Parameter | Description |
---|---|
Content-Type * | application/json |
X-Apikey * | Your API key (This can be found in the API Settings page after logging in.) Example value: 12345aaaaa67890aaaaa |
Body Parameters
* required parameters
Parameter | Description | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
code * | The received code. Not case-sensitive. Code must be 1-30 characters in length. Only alphanumeric and special characters are valid. |
||||||||||||||
request_date * |
Request date for verification. (This uses the time zone specified in the user's account.) Please note there are rare occasions where there may be differences between the requested time and the recognized time by the system due to network latency. Our system will check its own valid time and compare it with this parameter. Format: YYYY-MM-DD hh:mm:ss Example: 2015-11-04 14:10:32
|
Code sample for POST SMS Verification
"Request Example :
POST http://api.trumpia.com/rest/v1/{user_name}/verification/sms/{auth_id}"
{
"code" : "asdf1234",
"request_date" : "2015-11-04 12:00:01"
}
"Response Example:"
{
"status_code" : "MRCE0000",
"country_code" : 1,
"mobile_number" : "2003004000",
"code" : "asdf1234",
"verified_time" : "2015-11-04 12:00:01"
}
<?
//SMS Verification POST
include "request_rest.php";
$request_url = "http://api.trumpia.com/rest/v1/{user_name}/verification/sms";
$auth_id = 987987987987;
$request_url = $request_url . "/" . $auth_id;
$request_data = array(
"code" => "9pao8e98l9s0",
"request_date" => "2015-11-04 14:10:32"
);
$request_rest = new RestRequest();
$request_rest->setRequestURL($request_url);
$request_rest->setAPIKey("{api_key}");
$request_rest->setRequestBody(json_encode($request_data));
$request_rest->setMethod("POST");
$result = $request_rest->execute();
$response_status = $result[0];
$json_response_data = $result[1];
if ($response_status == "200") { //success
$response_data = json_decode($json_response_data);
echo "request_id : " . $response_data->request_id . "<br>";
} else {
echo $response_status ." - connection failure";
}
?>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="org.json.simple.JSONArray" %>
<%@ page import="org.json.simple.JSONObject" %>
<%@ page import="java.io.BufferedReader" %>
<%@ page import="java.io.IOException" %>
<%@ page import="java.io.InputStreamReader" %>
<%@ page import="java.io.OutputStream" %>
<%@ page import="java.io.OutputStreamWriter" %>
<%@ page import="java.io.Writer" %>
<%@ page import="java.net.HttpURLConnection" %>
<%@ page import="java.net.URL" %>
<html>
<title>SMS Verification Post Sample Code</title>
<body>
<%
String username = "username";
String auth_id = "987987987980";
String code = "9pao8e98l9s0";
String request_date = "2015-11-04 14:10:32";
JSONObject verificationPost = new JSONObject();
verificationPost.put("code", code);
verificationPost.put("request_date", request_date);
String urlStr = "http://api.trumpia.com/rest/v1/" + username + "/verification/sms/" + auth_id;
URL url = new URL(urlStr);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setUseCaches(false);
conn.setAllowUserInteraction(false);
conn.setRequestProperty("Content-type", "application/json");
conn.setRequestProperty("X-Apikey", "12345aaaaa67890aaaaa");
OutputStream outPutStream = conn.getOutputStream();
Writer writer = new OutputStreamWriter(outPutStream, "UTF-8");
writer.write(verificationPost.toJSONString());
writer.close();
outPutStream.close();
if (conn.getResponseCode() != 200) {
%>
Error : <%=conn.getResponseMessage()%>
<%
}else{
// Buffer the result into a string
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
StringBuilder sb = new StringBuilder();
String line;
while ((line = rd.readLine()) != null) {
sb.append(line);
}
rd.close();
conn.disconnect();
%>
Response : <%=sb.toString()%>
<%
}
%>
</body>
</html>
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
namespace samplecode
{
class SMSVerificationInfo
{
public string code { get; set; }
public string request_date { get; set; }
}
class Result
{
public string request_id { get; set; }
}
class SMSVerificationPost
{
static void Main()
{
RunAsync().Wait();
}
static async Task RunAsync()
{
using (var client = new HttpClient())
{
var apikey = "12345aaaaa67890aaaaa";
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Add("X-Apikey", string.Format("{0}", apikey));
var username = "username";
var auth_id = "987987987980";
//POST
var sms = new SMSVerificationInfo() { code = "9pao8e98l9s0", request_date = "2015-11-04 14:10:32" };
Uri postUrl = new Uri(string.Format("http://api.trumpia.com/rest/v1/{0}/verification/sms/{1}", username, auth_id));
var response = client.PostAsJsonAsync(postUrl, sms).Result;
if (response.IsSuccessStatusCode)
{
var p = response.Content.ReadAsAsync<Result>().Result;
string json = JsonConvert.SerializeObject(p);
Console.WriteLine(json);
}
}
}
}
}
POST Voice Verification
Verify a code for the voice authentication.
Resource Information
Response Formats | JSON |
Allowed Methods | POST |
URL | http://api.trumpia.com/rest/v1/{user_name}/authentication/voice/{auth_id} |
{user_name} | Your account username (this can be found in the Account Settings page after logging in.) |
Header Parameters
* required parameters
Parameter | Description |
---|---|
Content-Type * | application/json |
X-Apikey * | Your API key (This can be found in the API Settings page after logging in.) Example value: 12345aaaaa67890aaaaa |
Body Parameters
* required parameters
Parameter | Description | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
code * | The received code. Not case-sensitive. Code must be 1-30 characters in length. Only alphanumeric and special characters are valid. |
||||||||||||||
request_date * |
Request date for verification. (This uses the time zone specified in the user's account.) Please note there are rare occasions where there may be differences between the requested time and the recognized time by the system due to network latency. Our system will check its own valid time and compare it with this parameter. Format: YYYY-MM-DD hh:mm:ss Example: 2015-11-04 14:10:32
|
Code sample for POST Voice Verification
"Request Example :
POST http://api.trumpia.com/rest/v1/{user_name}/verification/voice/{auth_id}"
{
"code" : "asdf1234",
"request_date" : "2015-11-04 12:00:01"
}
"Response Example:"
{
"status_code" : "MRCE0000",
"number" : "2003004000",
"code" : "asdf1234",
"verified_time" : "2015-11-04 12:00:01"
}
<?
//Voice Verification POST
include "request_rest.php";
$request_url = "http://api.trumpia.com/rest/v1/{user_name}/verification/voice";
$auth_id = 987987987987;
$request_url = $request_url . "/" . $auth_id;
$request_data = array(
"code" => "9pao8e98l9s0",
"request_date" => "2015-11-04 14:10:32"
);
$request_rest = new RestRequest();
$request_rest->setRequestURL($request_url);
$request_rest->setAPIKey("{api_key}");
$request_rest->setRequestBody(json_encode($request_data));
$request_rest->setMethod("POST");
$result = $request_rest->execute();
$response_status = $result[0];
$json_response_data = $result[1];
if ($response_status == "200") { //success
$response_data = json_decode($json_response_data);
echo "request_id : " . $response_data->request_id . "<br>";
} else {
echo $response_status ." - connection failure";
}
?>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="org.json.simple.JSONArray" %>
<%@ page import="org.json.simple.JSONObject" %>
<%@ page import="java.io.BufferedReader" %>
<%@ page import="java.io.IOException" %>
<%@ page import="java.io.InputStreamReader" %>
<%@ page import="java.io.OutputStream" %>
<%@ page import="java.io.OutputStreamWriter" %>
<%@ page import="java.io.Writer" %>
<%@ page import="java.net.HttpURLConnection" %>
<%@ page import="java.net.URL" %>
<html>
<title>Voice Verification Post Sample Code</title>
<body>
<%
String username = "username";
String auth_id = "987987987980";
String code = "9pao8e98l9s0";
String request_date = "2015-11-04 14:10:32";
JSONObject verificationPost = new JSONObject();
verificationPost.put("code", code);
verificationPost.put("request_date", request_date);
String urlStr = "http://api.trumpia.com/rest/v1/" + username + "/verification/voice/" + auth_id;
URL url = new URL(urlStr);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setUseCaches(false);
conn.setAllowUserInteraction(false);
conn.setRequestProperty("Content-type", "application/json");
conn.setRequestProperty("X-Apikey", "12345aaaaa67890aaaaa");
OutputStream outPutStream = conn.getOutputStream();
Writer writer = new OutputStreamWriter(outPutStream, "UTF-8");
writer.write(verificationPost.toJSONString());
writer.close();
outPutStream.close();
if (conn.getResponseCode() != 200) {
%>
Error : <%=conn.getResponseMessage()%>
<%
}else{
// Buffer the result into a string
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
StringBuilder sb = new StringBuilder();
String line;
while ((line = rd.readLine()) != null) {
sb.append(line);
}
rd.close();
conn.disconnect();
%>
Response : <%=sb.toString()%>
<%
}
%>
</body>
</html>
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
namespace samplecode
{
class VoiceVerificationInfo
{
public string code { get; set; }
public string request_date { get; set; }
}
class Result
{
public string request_id { get; set; }
}
class VoiceVerificationPost
{
static void Main()
{
RunAsync().Wait();
}
static async Task RunAsync()
{
using (var client = new HttpClient())
{
var apikey = "12345aaaaa67890aaaaa";
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Add("X-Apikey", string.Format("{0}", apikey));
var username = "username";
var auth_id = "987987987980";
//POST
var voice = new VoiceVerificationInfo() { code = "9pao8e98l9s0", request_date = "2015-11-04 14:10:32" };
Uri postUrl = new Uri(string.Format("http://api.trumpia.com/rest/v1/{0}/verification/voice/{1}", username, auth_id));
var response = client.PostAsJsonAsync(postUrl, voice).Result;
if (response.IsSuccessStatusCode)
{
var p = response.Content.ReadAsAsync<Result>().Result;
string json = JsonConvert.SerializeObject(p);
Console.WriteLine(json);
}
}
}
}
}