Created
September 25, 2014 01:26
-
-
Save Furzel/d1e4d94c7be572313263 to your computer and use it in GitHub Desktop.
Basic Front contact API example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var https = require('https'); | |
var apiKey = '*** YOUR API KEY ***', | |
companySlug = '*** YOUR COMPANY SLUG ***'; | |
var data = { | |
name: 'Arthur Dent', | |
description: 'Earthman', | |
fields: [ | |
{ | |
source: 'email', | |
handle: 'arthur@sandwichmaker.com' | |
}, { | |
source: 'phone', | |
handle: '+123456789' | |
}, { | |
source: 'twitter', | |
handle: '@arthurd' | |
} | |
], | |
links: [ | |
{url: 'https://en.wikipedia.org/wiki/Douglas_Adams'}, | |
{url: 'http://xkcd.com/'} | |
] | |
}; | |
var dataString = JSON.stringify(data); | |
var options = { | |
host: 'webhook.frontapp.com', | |
path: '/api/1/contacts', | |
auth: companySlug + ':' + apiKey, | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json', | |
'Content-Length': dataString.length | |
} | |
}; | |
var req = https.request(options, function (res) { | |
if (res.statusCode === 202) | |
console.log('OK'); | |
else | |
console.log('ERROR'); | |
}); | |
req.write(dataString); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment