Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/vreg/node_modules/smartystreets-javascript-sdk/examples/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //home/corals/vreg/node_modules/smartystreets-javascript-sdk/examples/us_zipcode.js
const SmartyStreetsSDK = require("smartystreets-javascript-sdk");
const SmartyStreetsCore = SmartyStreetsSDK.core;
const Lookup = SmartyStreetsSDK.usZipcode.Lookup;

// for Server-to-server requests, use this code:
// let authId = process.env.SMARTY_AUTH_ID;
// let authToken = process.env.SMARTY_AUTH_TOKEN;
// const credentials = new SmartyStreetsCore.StaticCredentials(authId, authToken);

// for client-side requests (browser/mobile), use this code:
let key = process.env.SMARTY_WEBSITE_KEY;
const credentials = new SmartyStreetsCore.SharedCredentials(key);

let clientBuilder = new SmartyStreetsCore.ClientBuilder(credentials);
	// .withBaseUrl("");
let client = clientBuilder.buildUsZipcodeClient();

// Documentation for input fields can be found at:
// https://smartystreets.com/docs/us-zipcode-api#input-fields

let lookup1 = new Lookup();
lookup1.inputId = "01189998819991197253"; // Optional ID from your system
lookup1.zipCode = "49786";

let lookup2 = new Lookup();
lookup2.inputId = "dfc33cb6-829e-4fea-aa1b-b6d6580f0817";
lookup2.city = "Provo";
lookup2.state = "UT";
lookup2.zipCode = "84604";

let lookup3 = new Lookup();
lookup3.city = "Phoenix";
lookup3.state = "AZ";

let batch = new SmartyStreetsCore.Batch();
batch.add(lookup1);
batch.add(lookup2);
batch.add(lookup3);

client.send(batch)
	.then(viewResults)
	.catch(console.log);

function viewResults(response) {
	response.lookups.map(lookup => lookup.result.map(candidate => {
		candidate.cities.map(city => console.log(city.city));
		// candidate.zipcodes.map(zipcode => console.log(zipcode.zipcode));
	}));
}

Spamworldpro Mini