Briteverify Developers Guide
Briteverify Developers Guide
Developer Guide
Draft
Table of Contents
Developing with BriteVerify ...................................................................................................................... 1
Overview ................................................................................................................................................. 1
Types Verification................................................................................................................................ 2
BriteVerify Authorization & Authentication ....................................................................................... 3
How to BriteVerify.................................................................................................................................. 4
BriteForm Plugin.................................................................................................................................. 4
BriteVerify jQuery Functions............................................................................................................... 7
BriteVerify Web Services API ............................................................................................................. 9
BriverVerify API ................................................................................................................................... 10
Name .................................................................................................................................................. 10
Email .................................................................................................................................................. 11
Address............................................................................................................................................... 12
Phone.................................................................................................................................................. 13
IP Address (Coming Soon) ................................................................................................................ 14
More Web Service Examples ................................................................................................................ 15
Overview
BriteVerify is a suite of RESTful Web Services and jQuery plug-ins for the real-time verification
Name
Email
Postal Address
Phone
IP Address
The jQuery plug-ins are designed to be used inside the browser and require no backend server
integration. Simply cut and past a code snippet into the body of any HTML page with a form and
you are ready to BriteVerify. For developers who wish to integrate on the backend, BriteVerify
RESTful Web Services can be consumed with nothing more than an HTTP client and an XML or
JSON parser in almost any language or platform (.NET, Perl, PHP, Ruby, Java...).
Types Verification
Name
The name verification service applies profanity filters to the name then attempts to identify
gender.
Email
The email service provides 3 escalating steps to ensure that a consumer’s email is correct and
deliverable.
In the third step, account verification, BriteVerify opens an SMTP conversation with the email
server and attempts to validate that the account is active and capable or receiving email. The service
Postal Address
The default behavior of the Postal Address verification is to ensure not only that the address is
fully coded but also that it is USPS Delivery Point Verified, or DPV. This means that the address is
not simple correct but that it is capable of receiving mail from the US Postal Service.
Phone
By default, the standard phone service applies a simple area code + prefix check against a
database of known area code and prefix matches. Premium phone verification ensures that the
phone number is a dialable number and is capable of filtering based on phone type (mobile, landline,
NOTE: We can only ensure that a number is dialable, not that is necessarily connected and
working. Dialable means that the North American Numbering Plan (NNAP) has assigned
the number to a service provider. This does not mean that the number is not out of
service. There is no way to ensure that a number has not been disconnected other than
employed. The jQuery plug-ins use domain-based authorization, while the standard Web Service
clients use traditional basic HTTP authentication. Both of these methods are available over HTTPS.
Domain-Based Authorization
Since the jQuery-based calls execute directly in the browser traditional basic HTTP
authentication is not an option as the username and password are easily exposed. To get around this
issue BriteVerify references each request against a user supplied list of authorized domains. If the
request comes from a domain not on the list, BriteVerify responds with an error and does nothing.
During testing a certain number of test transactions can come from unauthorized domains before
Services. Once your account is active, each request from your servers must include your username
https://myusername:[email protected]/emails.xml
How to BriteVerify
There are three different ways to get up and running with BriteVerify :
BriteForm Plugin
The BriteForm Plugin automatically binds visual verification functions to any field on the page
that it recognizes as being verifiable. This is the simplest method since all that is required to verify
any form on a given web page in the inclusion of the required scripts and stylesheets. Then once a
user completes a BriteVerified field such as email a "verifying message" will display. If the email is
invalid an error message replace the "verifying message". Otherwise, the message will disappear.
Integrating using the BriteForm Plugin is as simple as cut and past. Just log in to your
BriteVerify account, click "Get Code" and cut and past HTML code snippet just about the close
body tag (</body>) of the page with a form or forms you wish to validate.
function bvInit(){
// This code binds to every form on the page.
// In production it is advised that you explicitly bind
// to only those forms that you wish to verify.
//
// ala: jQuery("#myFormId").briteForm();
//
jQuery("form").each(function(i){
var bf = jQuery(this).briteForm();
bf.findFields();
// explicit binding
// For address, a css selector for street and zip are required.
// bf.addPhoneFields("#phone_number2_areacode", "#phone_number2_prefix",
// "#phone_number2_suffix");
// The null value we are passing with the name is a the gender input/select. If a
// css selector is passed for gender, the service will attempt to populate it with
// either "M" or "F". So in the case of a select it will
// auto select the gender based on the name.
});
}
</script>
<!-- End BriteVerify Code -->
And that's it! BriteVerify will now start verifying your form.
In order for BriteVerify to magically verify your forms, you do need to make sure that either the
name or id attribute of fields include BriteVerify keywords, such as email, phone, street, city, state,
zip, etc. So in the example above, BriteVerify is able to validate the email field because it has the
word "email" somewhere in the id and or name attributes. As a best practice, use the id attribute to
Using it, JavaScript developers access programmatically any of the BriteVerifiy services. The
functions follow a similar pattern to traditional jQuery AJAX calls in that an optional callback
function may be passed to that will execute when the call completes. All BriteVerify functions are
All the BriteVerify functions follow a similar pattern for their method signature: value, callback.
The first parameter is the value to be verified, either a simple string for functions such as email, or
an object, as with address. The second parameter it the callback function to be executed when the
verification is completed. This function will always have the resulting object passed into it. This is
jQuery.briteVerify.email(“[email protected]”, function(email){
alert(email.address); // [email protected]
}
Handling Errors
Errors Array
If the value cannot be verified, the response object will contain an array of errors. The errors
array is an array of arrays. Each individual error is an array where the first value is the name of the
attribute on which the error occurred and the second is the error message itself. Almost always there
is only one error per field. So checking for additional errors is usually pointless. However, it can be
valuable to know to which part of the value the error applies. For example, with the email response
object contains the address, domain, and account attributes and the error will apply to one of those.
jQuery.briteVerify.email(“[email protected]”, function(email){
// first check to see if there are any errors
if(email.errors){
// get the first error in the array
var error = email.errors[0];
var attr = error[0];
var msg = error[1];
// so a different error message base on the attr
if(attr == “address”){
alert(“incorrect email syntax”);
}else if(attr == “account”){
alert(“the account was not found on the domain”);
}else if(attr == “domain”){
alert(“the is not valid”);
}
}
}
object for the errors array. It makes coding a little easier and cleaner.
jQuery.briteVerify.email(“[email protected]”, function(email){
// first check to see if there are any errors
if(email.errors_json){
// so a different error message base on the attr
if(email.errors_json.address){
alert(“incorrect email syntax”);
}else if(email.errors_json.account){
alert(“the account was not found on the domain”);
}else if(email.errors_json.domain){
alert(“the is not valid”);
}
}
}
account balance reaches 0, an error will be returned on the “user” attribute. It is a best practice to
ignore these messages, but they can be helpful for testing purposes. A notification will be sent out
prior to any user account hitting a zero balance, or if auto-billing is enabled a billing notification will
be sent.
jQuery.briteVerify.email(“[email protected]”, function(email){
// first check to see if there are any errors
if(email.errors_json){
// so a different error message base on the attr
if(email.errors_json.user){
alert(“user account: ” + email.errors_json.user); //”overbalance”
}
}
}
Every resource, like Name, Email, Address, Phone, and IPAddress, has its own URL in accordance
Although the best practice is to use POST to verify a given resource, a GET method is available.
However, you must pass your secret API key in the parameter list as this very method does not
require HTTP authentication. Your secret API key can be found by logging into your BriteVerify
Acount. Using the verify GET URL you can explore the resulting xml of various calls. It does
follow the Rails field naming convention, which is “object[attribute],” as illustrated in the examples
below.
Result
Both calls should respond with an HTTP status code of “201 Created” and the following xml
response document.
BriverVerify API
Name
jQuery.briteVerify.name(name, callbackFunction)
Accepts the full name of a consumer and a callback function. A name object is passed into the
name.first_name;
name.middle;
name.last_name;
name.prefix;
name.suffix;
name.gender;
name.errors; // an errors array with all errors returned by the service
name.errors_json; // an errors JSON object with all errors returned by the service
Example
jQuery("#myNameFieldId").change(function(){
// in this example there is just one name field into which the user types there
full name
// the callback function should have the name object passed back into it.
jQuery.briteVerify.name(this.value, function(name){
if(name.errors){
alert("Your name is not valid. Please correct");
}else{
var fullname = name.first_name + " " + name.middle + " " + name.last_name;
alert(fullname + " is a valid name");
}
});
});
POST https://api.briteverify.com/names.xml
curl -u jdoe:password -H 'Content-Type: application/xml' -d '<name><fullname>James
McLachlan</fullname></name>' http://api.briteverify.com/names.xml
Response
Status: 201 Created
<?xml version="1.0" encoding="UTF-8"?>
<name>
<first-name>James</first-name>
<fullname>James McLachlan</fullname>
<gender>male</gender>
<last-name>McLachlan</last-name>
<middle-name> </middle-name>
</name>
GET Example
http://api.briteverify.com/names/verify.xml?name[fullname]=james+mclachlan&apikey=8
971398-3e72-2343-ghsjdfg-8879987fds
Parameters
name[fullname]
name[first_name]
name[last_name]
name[middle_name]
Email
jQuery.briteVerify.email(email, callbackFunction)
Accepts an email string and a callback function. An email object is passed into the callback
email.address; // [email protected]
email.domain; // nodo.com
email.account; // jdoe
email.errors; // [[“domain”, “does not exist”]]
email.errors_json; // {account : “not found on nodo.com”}
Example
jQuery("#myEmailFieldId").change(function(){
jQuery.briteVerify.email(this.value, function(email){
if(email.errors){
if(email.errors_json.domain){
alert("Your email domain " + email.errors_json.domain);
}else if(email.errors_json.address){
alert("Your email " + email.errors_json.address);
}else if(email.errors_json.account){
alert("Your account " + email.errors_json.account);
}
}
});
});
POST https://api.briteverify.com/emails.xml
curl -u jdoe:password -H 'Content-Type: application/xml' -d
'<email><address>[email protected]</address></email>'
http://api.briteverify.com/emails.xml
Response
Status: 201 Created
GET Example
http://api.briteverify.com/emails/verify.xml?email[address][email protected]&ap
ikey=8971398-3e72-2343-ghsjdfg-8879987fds
Parameters
email[address]
Address
jQuery.briteVerify.address(address, callbackFunction)
Accepts an address JSON object and a callback function. An address object is passed into the
address.street;
address.unit;
address.city;
address.state;
address.zip;
address.plus4;
address.address_type;
address.errors;
address.errors_json
Example
jQuery("#myZipFieldId").change(function(){
// check first to see if the street field has something in it
var streetVal = jQuery("#myStreetFieldId").val();
if(streetVal){
var myAddress = { street : streetVal, unit : jQuery("#myUnitFieldId").val(),
city : jQuery("#myCityFieldId").val(), state : jQuery("#myStateFieldId").val(), zip
: jQuery("#myZipFieldId").val() }
};
jQuery.briteVerify.address(myAddress, function(address){
if(address.errors){
alert("Address not found.");
}
});
});
POST https://api.briteverify.com/addresses.xml
curl -u jdoe:password -H 'Content-Type: application/xml' -d '<address><street>120 N
cedar</street><zip>28210</zip></address>' https://api.briteverify.com/addresses.xml
Response
Status: 201 Created
<?xml version="1.0" encoding="UTF-8"?>
<address>
<address-type>Highrise</address-type>
<city>Charlotte</city>
<county>Mecklenburg</county>
<plus4>1292</plus4>
<state>NC</state>
<street>120 N Cedar St </street>
<unit nil="true"></unit>
<zip>28202</zip>
</address>
GET Example
http://api.briteverify.com/addresses/verify.xml?address[street]=120+nowhere&address
[zip]=28202&apikey=8971398-3e72-2343-ghsjdfg-8879987fds
Parameters
address[street]
address[unit]
address[city]
address[state]
address[zip]
Phone
jQuery.briteVerify.phone(phone, callbackFunction, options)
Accepts a phone string and a callback function. A phone object should be passed into the
callback function to hold the result returned when processing is complete. Options are optional and
there is currently only a premium flag is supported. If the premium option is passed as true, then the
phone.number; // 7041231234
phone.areacode; // 704
phone.prefix; // 123
phone.suffix; // 1234
phone.city; // Charlotte
phone.county; // Mecklenburg
phone.country; // US
phone.errors; // { number : "is not valid" }
jQuery("#myPhoneFieldId").change(function(){
jQuery.briteVerify.phone(this.value, function(phone){
if(phone.errors){
alert("phone is not valid");
}
});
});
POST https://api.briteverify.com/phones.xml
curl -u jdoe:password -H 'Content-Type: application/xml' -d '<phone><number>704 525
5526</number></phone>' https://api.briteverify.com/phones.xml
Response
Status: 201 Created
<?xml version="1.0" encoding="UTF-8"?>
<phone>
<areacode>704</areacode>
<city>Charlotte</city>
<ext nil="true"></ext>
<number>704 525 5526</number>
<prefix>525</prefix>
<service-type>unknown</service-type>
<suffix>5526</suffix>
</phone>
GET Examples
http://api.briteverify.com/phones/verify.xml?phone[number]=7041231234&apikey=897139
8-3e72-2343-ghsjdfg-8879987fds
Parameters
phone[number]
phone[premium] (true or false)
ip.address; // 96.10.172.152
ip.longitude;
ip.latitude;
ip.zip;
ip.region;
ip.city;
ip.country;
ip.isp;
Example
jQuery(document).load(function(){
jQuery.briteVerify.locateIP(function(ip){
alert(ip.city);
});
});
BriteVerify provides a RESTful Web Service API for backend server integration. Any language
that supports XML or JSON and HTTP can consume these services. The examples below illustrate a
very basic integration of the email service using the Ruby programming language.
We will be using the NET/HTTP libraries that are part of the core Ruby language. It is
Example
# POST it to BriteVerify
res = Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }
# When there is a client error and the code is 422 then the email is invalid
when Net::HTTPClientError
if res.code == "422"
# This means that the email is invalid. The xml response will be a list of
errors
# <errors>
# <error>Account jdoe not found at briteverify.com</error>
# </errors>
BriteVerify on Rails
Our Web Services work perfectly with ActiveResource, the Web Service client for Ruby on
Rails. The integration in this case is extremely simple, but it should prove equally simple for any
Example