Last active
August 8, 2016 22:50
-
-
Save dangerouse/e0d64500c370a8865ea8ddf81be238b9 to your computer and use it in GitHub Desktop.
CloudSponge Widget Reference - Post selected contacts to your server
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<!-- | |
Include the script anywhere on your page, usually in the head | |
(don't forget to replace `localhost-only` with your own CloudSponge Widget Key) | |
--> | |
<script src="//api.cloudsponge.com/widget/localhost-only.js"></script> | |
<script> | |
// extra widget options go here: | |
cloudsponge.init({ | |
afterSubmitContacts: function(contacts, source, owner) { | |
var url = "/path/to/your/contacts/endpoint", | |
http = new XMLHttpRequest(), | |
payload = {contacts: contacts, source: source, owner: owner}; | |
// crate the http connection | |
http.open("POST", url, true); | |
// Send the proper header information along with the request | |
http.setRequestHeader("Content-type", "application/json"); | |
http.onreadystatechange = function() {// Call a function when the state changes. | |
if(http.readyState == 4 && http.status == 200) { | |
alert(http.responseText); | |
} | |
} | |
http.send(JSON.stringify(payload)); | |
} | |
}); | |
</script> | |
</head> | |
<body> | |
<a class="cloudsponge-launch">Add from Address Book</a> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment