Skip to content

Instantly share code, notes, and snippets.

@dangerouse
Created February 4, 2015 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dangerouse/ef3b9a3eae39b53740b6 to your computer and use it in GitHub Desktop.
Save dangerouse/ef3b9a3eae39b53740b6 to your computer and use it in GitHub Desktop.
CloudSponge Widget Example - Web Hooks (using jquery)
<!DOCTYPE html>
<html>
<body>
<!-- Any link with a class="cs_import" will start the import process -->
<a class="cs_import">Add from Address Book</a>
<!-- Include the script anywhere on your page -->
<script>
// set any options here, for this example, we'll simply populate the contacts in the textarea above
window.csPageOptions = {
// don't include the domain_key here, it's part of your widget script, below
afterSubmitContacts: function(contacts, source, owner) {
var webhookURL = "THE WEB HOOK URL",
data = {contacts: contacts, source: source, owner: owner};
$.post(webhookURL, data);
}
};
// Asynchronously include the widget library.
(function(u){
var d=document,s='script',a=d.createElement(s),m=d.getElementsByTagName(s)[0];
a.async=1;a.src=u;m.parentNode.insertBefore(a,m);
})('//api.cloudsponge.com/widget/YOUR_WIDGET_SCRIPT.js');
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment