PAV-I PHP CURL

From CDYNE Wiki
Jump to navigation Jump to search

PAV-I will be discontinued in March 2013. We sincerely appreciate your support and regret any inconvenience this may cause.

This is a simple PHP CURL code example that returns a verified international address.

You must enter a vaild License Key for this code to work properly. (Trial keys are fully functional)

 1 <?php
 2 
 3 $LicenseKey = "your lk here";
 4 
 5 $json = '{
 6 		"AddressFields":[{
 7 				"Key": "ADDR",
 8 				"Value" : "Rose House, 51-59 Circular Road, Isle of Man, IM1 1AZ, United Kingdom"
 9 			}]
10 		,"ReturnFields":["RESCODE","ADDR","OUTPUTSTATUS","MATCHLVL"]
11 		,"LicenseKey":"'.$LicenseKey.'"
12 		,"ReturnNativeOutput":false
13 	}';
14 
15 $url = 'http://pav3.cdyne.com/i/PavInternationalService.svc/VerifyAddressInternational';
16  
17 $cURL = curl_init();
18  
19 curl_setopt($cURL,CURLOPT_URL,$url);
20 curl_setopt($cURL,CURLOPT_POST,true);
21 curl_setopt($cURL,CURLOPT_POSTFIELDS,$json);
22 curl_setopt($cURL,CURLOPT_RETURNTRANSFER, true);  
23 curl_setopt($cURL, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Accept: application/json'));
24  
25 $result = curl_exec($cURL);
26  
27 curl_close($cURL);
28  
29 print_r($result);
30 
31 ?>