Sample Codes
HTTP | C | cURL | C# | GO | JAVA | JavaScript | NodeJS | Objective-C
OCaml | PHP | Python | Ruby | Shell | Swift
Alternatively, you can find the sample code on our GitHub Account.
.
HTTP
POST /email_verification/ HTTP/1.1 Host: api.evasrv.com Cache-Control: no-cache Content-Type: application/x-www-form-urlencoded email=username%40domain.com&user_API_token=YOUR-EV-APP-API-TOKEN&free=true&disposable=true&did_you_mean=true&role=true&bad=true&ev_score=true
C
CURL *hnd = curl_easy_init(); curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST"); curl_easy_setopt(hnd, CURLOPT_URL, "https://api.evasrv.com/email_verification/"); struct curl_slist *headers = NULL; headers = curl_slist_append(headers, "content-type: application/x-www-form-urlencoded"); headers = curl_slist_append(headers, "cache-control: no-cache"); curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "email=username%40domain.com&user_API_token=YOUR-EV-APP-API-TOKEN&free=true&disposable=true&did_you_mean=true&role=true&bad=true&ev_score=true"); CURLcode ret = curl_easy_perform(hnd);
cURL
curl -X POST -H "Cache-Control: no-cache" -H "Content-Type: application/x-www-form-urlencoded" -d 'email=username@domain.com&user_API_token=YOUR-EV-APP-API-TOKEN&free=true&disposable=true&did_you_mean=true&role=true&bad=true&ev_score=true' "https://api.evasrv.com/email_verification/"
C#
var client = new RestClient("https://api.evasrv.com/email_verification/"); var request = new RestRequest(Method.POST); request.AddHeader("content-type", "application/x-www-form-urlencoded"); request.AddHeader("cache-control", "no-cache"); request.AddParameter("application/x-www-form-urlencoded", "email=username%40domain.com&user_API_token=YOUR-EV-APP-API-TOKEN&free=true&disposable=true&did_you_mean=true&role=true&bad=true&ev_score=true", ParameterType.RequestBody); IRestResponse response = client.Execute(request);
GO
package main import ( "fmt" "strings" "net/http" "io/ioutil" ) func main() { url := "https://api.evasrv.com/email_verification/" payload := strings.NewReader("email=username%40domain.com&user_API_token=YOUR-EV-APP-API-TOKEN&free=true&disposable=true&did_you_mean=true&role=true&bad=true&ev_score=true") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("cache-control", "no-cache") req.Header.Add("content-type", "application/x-www-form-urlencoded") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) }
JAVA: OK HTTP
OkHttpClient client = new OkHttpClient(); MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); RequestBody body = RequestBody.create(mediaType, "email=username%40domain.com&user_API_token=YOUR-EV-APP-API-TOKEN&free=true&disposable=true&did_you_mean=true&role=true&bad=true&ev_score=true"); Request request = new Request.Builder() .url("https://api.evasrv.com/email_verification/") .post(body) .addHeader("cache-control", "no-cache") .addHeader("content-type", "application/x-www-form-urlencoded") .build(); Response response = client.newCall(request).execute();
JAVA: UniRest
HttpResponse<String> response = Unirest.post("https://api.evasrv.com/email_verification/") .header("cache-control", "no-cache") .header("content-type", "application/x-www-form-urlencoded") .body("email=username%40domain.com&user_API_token=YOUR-EV-APP-API-TOKEN&free=true&disposable=true&did_you_mean=true&role=true&bad=true&ev_score=true") .asString();
JavaScript: JQuery AJAX
var settings = { "async": true, "crossDomain": true, "url": "https://api.evasrv.com/email_verification/", "method": "POST", "headers": { "cache-control": "no-cache", "content-type": "application/x-www-form-urlencoded" }, "data": { "email": "username@domain.com", "user_API_token": "YOUR-EV-APP-API-TOKEN", "free": "true", "disposable": "true", "did_you_mean": "true", "role": "true", "bad": "true" } } $.ajax(settings).done(function (response) { console.log(response); });
JavaScript: XHR
var data = "email=username%40domain.com&user_API_token=YOUR-EV-APP-API-TOKEN&free=true&disposable=true&did_you_mean=true&role=true&bad=true&ev_score=true"; var xhr = new XMLHttpRequest(); xhr.withCredentials = true; xhr.addEventListener("readystatechange", function () { if (this.readyState === 4) { console.log(this.responseText); } }); xhr.open("POST", "https://api.evasrv.com/email_verification/"); xhr.setRequestHeader("cache-control", "no-cache"); xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded"); xhr.send(data);
NodeJS: Native
var qs = require("querystring"); var http = require("https"); var options = { "method": "POST", "hostname": "api.evasrv.com", "port": null, "path": "/email_verification/", "headers": { "cache-control": "no-cache", "content-type": "application/x-www-form-urlencoded" } }; var req = http.request(options, function (res) { var chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { var body = Buffer.concat(chunks); console.log(body.toString()); }); }); req.write(qs.stringify({ email: 'username@domain.com', user_API_token: 'YOUR-EV-APP-API-TOKEN', free: 'true', disposable: 'true', did_you_mean: 'true', role: 'true', bad: 'true' })); req.end();
NodeJS: Request
var request = require("request"); var options = { method: 'POST', url: 'https://api.evasrv.com/email_verification/', headers: { 'content-type': 'application/x-www-form-urlencoded', 'cache-control': 'no-cache' }, form: { email: 'username@domain.com', user_API_token: 'YOUR-EV-APP-API-TOKEN', free: 'true', disposable: 'true', did_you_mean: 'true', role: 'true', bad: 'true' } }; request(options, function (error, response, body) { if (error) throw new Error(error); console.log(body); });
NodeJS: UniRest
var unirest = require("unirest"); var req = unirest("POST", "https://api.evasrv.com/email_verification/"); req.headers({ "content-type": "application/x-www-form-urlencoded", "cache-control": "no-cache" }); req.form({ "email": "username@domain.com", "user_API_token": "YOUR-EV-APP-API-TOKEN", "free": "true", "disposable": "true", "did_you_mean": "true", "role": "true", "bad": "true" }); req.end(function (res) { if (res.error) throw new Error(res.error); console.log(res.body); });
Objective-C: NSURL
#import <Foundation/Foundation.h> NSDictionary *headers = @{ @"cache-control": @"no-cache", @"content-type": @"application/x-www-form-urlencoded" }; NSMutableData *postData = [[NSMutableData alloc] initWithData:[@"email=username@domain.com" dataUsingEncoding:NSUTF8StringEncoding]]; [postData appendData:[@"&user_API_token=YOUR-EV-APP-API-TOKEN" dataUsingEncoding:NSUTF8StringEncoding]]; [postData appendData:[@"&free=true" dataUsingEncoding:NSUTF8StringEncoding]]; [postData appendData:[@"&disposable=true" dataUsingEncoding:NSUTF8StringEncoding]]; [postData appendData:[@"&did_you_mean=true" dataUsingEncoding:NSUTF8StringEncoding]]; [postData appendData:[@"&role=true" dataUsingEncoding:NSUTF8StringEncoding]]; [postData appendData:[@"&bad=true" dataUsingEncoding:NSUTF8StringEncoding]]; [postData appendData:[@"&ev_score=true" dataUsingEncoding:NSUTF8StringEncoding]]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.evasrv.com/email_verification/"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0]; [request setHTTPMethod:@"POST"]; [request setAllHTTPHeaderFields:headers]; [request setHTTPBody:postData]; NSURLSession *session = [NSURLSession sharedSession]; NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { if (error) { NSLog(@"%@", error); } else { NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response; NSLog(@"%@", httpResponse); } }]; [dataTask resume];
OCaml: CoHTTP
open Cohttp_lwt_unix open Cohttp open Lwt let uri = Uri.of_string "https://api.evasrv.com/email_verification/" in let headers = Header.init () |> fun h -> Header.add h "cache-control" "no-cache" |> fun h -> Header.add h "content-type" "application/x-www-form-urlencoded" in let body = Cohttp_lwt_body.of_string "email=username%40domain.com&user_API_token=YOUR-EV-APP-API-TOKEN&free=true&disposable=true&did_you_mean=true&role=true&bad=true&ev_score=true" in Client.call ~headers ~body `POST uri >>= fun (res, body_stream) -> (* Do stuff with the result *)
PHP: HTTP v1
<?php $request = new HttpRequest(); $request->setUrl('https://api.evasrv.com/email_verification/'); $request->setMethod(HTTP_METH_POST); $request->setHeaders(array( 'content-type' => 'application/x-www-form-urlencoded', 'cache-control' => 'no-cache' )); $request->setContentType('application/x-www-form-urlencoded'); $request->setPostFields(array( 'email' => 'username@domain.com', 'user_API_token' => 'YOUR-EV-APP-API-TOKEN', 'free' => 'true', 'disposable' => 'true', 'did_you_mean' => 'true', 'role' => 'true', 'bad' => 'true' )); try { $response = $request->send(); echo $response->getBody(); } catch (HttpException $ex) { echo $ex; }
PHP: PECL HTTP
<?php $client = new http\Client; $request = new http\Client\Request; $body = new http\Message\Body; $body->append(new http\QueryString(array( 'email' => 'username@domain.com', 'user_API_token' => 'YOUR-EV-APP-API-TOKEN', 'free' => 'true', 'disposable' => 'true', 'did_you_mean' => 'true', 'role' => 'true', 'bad' => 'true' ))); $request->setRequestUrl('https://api.evasrv.com/email_verification/'); $request->setRequestMethod('POST'); $request->setBody($body); $request->setHeaders(array( 'content-type' => 'application/x-www-form-urlencoded', 'cache-control' => 'no-cache' )); $client->enqueue($request)->send(); $response = $client->getResponse(); echo $response->getBody();
PHP: CURL
<?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "https://api.evasrv.com/email_verification/", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "email=username%40domain.com&user_API_token=YOUR-EV-APP-API-TOKEN&free=true&disposable=true&did_you_mean=true&role=true&bad=true&ev_score=true", CURLOPT_HTTPHEADER => array( "cache-control: no-cache", "content-type: application/x-www-form-urlencoded" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }
Python: Python3
import http.client conn = http.client.HTTPSConnection("api.evasrv.com") payload = "email=username%40domain.com&user_API_token=YOUR-EV-APP-API-TOKEN&free=true&disposable=true&did_you_mean=true&role=true&bad=true&ev_score=true" headers = { 'cache-control': "no-cache", 'content-type': "application/x-www-form-urlencoded" } conn.request("POST", "/email_verification/", payload, headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8"))
Python: Requests
import requests url = "https://api.evasrv.com/email_verification/" payload = "email=username%40domain.com&user_API_token=YOUR-EV-APP-API-TOKEN&free=true&disposable=true&did_you_mean=true&role=true&bad=true&ev_score=true" headers = { 'cache-control': "no-cache", 'content-type': "application/x-www-form-urlencoded" } response = requests.request("POST", url, data=payload, headers=headers) print(response.text)
Ruby
require 'uri' require 'net/http' url = URI("https://api.evasrv.com/email_verification/") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Post.new(url) request["cache-control"] = 'no-cache' request["content-type"] = 'application/x-www-form-urlencoded' request.body = "email=username%40domain.com&user_API_token=YOUR-EV-APP-API-TOKEN&free=true&disposable=true&did_you_mean=true&role=true&bad=true&ev_score=true" response = http.request(request) puts response.read_body
Shell: Wget
wget --quiet \ --method POST \ --header 'cache-control: no-cache' \ --header 'content-type: application/x-www-form-urlencoded' \ --body-data 'email=username%40domain.com&user_API_token=YOUR-EV-APP-API-TOKEN&free=true&disposable=true&did_you_mean=true&role=true&bad=true&ev_score=true' \ --output-document \ - https://api.evasrv.com/email_verification/
Shell: HTTPie
http --form POST https://api.evasrv.com/email_verification/ \ cache-control:no-cache \ content-type:application/x-www-form-urlencoded \ email=username@domain.com \ user_API_token=YOUR-EV-APP-API-TOKEN \ free=true \ disposable=true \ did_you_mean=true \ role=true \ bad=true \ ev_score=true
Shell: CURL
curl --request POST \ --url https://api.evasrv.com/email_verification/ \ --header 'cache-control: no-cache' \ --header 'content-type: application/x-www-form-urlencoded' \ --data 'email=username%40domain.com&user_API_token=YOUR-EV-APP-API-TOKEN&free=true&disposable=true&did_you_mean=true&role=true&bad=true&ev_score=true'
Swift
import Foundation let headers = [ "cache-control": "no-cache", "content-type": "application/x-www-form-urlencoded" ] let postData = NSMutableData(data: "email=username@domain.com".data(using: String.Encoding.utf8)!) postData.append("&user_API_token=YOUR-EV-APP-API-TOKEN".data(using: String.Encoding.utf8)!) postData.append("&free=true".data(using: String.Encoding.utf8)!) postData.append("&disposable=true".data(using: String.Encoding.utf8)!) postData.append("&did_you_mean=true".data(using: String.Encoding.utf8)!) postData.append("&role=true".data(using: String.Encoding.utf8)!) postData.append("&bad=true".data(using: String.Encoding.utf8)!) postData.append("&ev_score=true".data(using: String.Encoding.utf8)!) let request = NSMutableURLRequest(url: NSURL(string: "https://api.evasrv.com/email_verification/")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume()
<< Back to Email Verification API for Developers