This document is a work-in-progress that is currently being written as development on the API takes place. It is in no way complete, but offers developers a place to catch a glimpse of what the future API will look like and how it will function.
Starting with the 3.0 release of Clip and Share, an API will be offered in order to make building on new features much easier. For example, adding on a new social network that hasn't already been included can be much easier when using the API. Rather than writing lines and lines and lines of repetitive code, only a few, simple JavaScript objects need to be created and then fed to the API.
All Clip and Share API functions are called from the top-level object of clipAndShare.*. This object serves as the parent to every API call for the sake of simplicity and does nothing when called by itself.
A function for testing the API has been added for convenience. To ensure that you are calling the API properly, simply include the following code in your background layer:
clipAndShare.test()
This function does nothing more than call up an alert dialog informing you that your API implementation is working properly.
Social networking sites are added using the following API call:
clipAndShare.addNetwork(object networkInfo)
The networkInfo object can include the following attributes:
Attribute | Required | Type | Description |
---|---|---|---|
networkName | Yes | String | name of network |
baseURL | Yes | String | portion of share endpoint preceding the question mark |
sharePages | No | Boolean | defines whether pages will be shared; defaults to true |
shareLinks | No | Boolean | defines whether links will be shared; defaults to true |
shareImages | No | Boolean | defines whether images will be shared; defaults to false |
shareQuotes | No | Boolean | defines whether quotes will be shared; defaults to false |
titleAttribute | No | String | the URL attribute defining the title of the item shared |
linkAttribute | Yes | String | the URL attribute defining the link to the item shared |
otherQuery | No | Associative Array | other site-specific querys |
Here's an example of how Facebook would be added to the extension:
networkInfo = new Object(); networkInfo.networkName = "Facebook"; networkInfo.baseURL = "https://www.facebook.com/dialog/feed"; networkInfo.shareImages = True; networkInfo.shareQuotes = True; networkInfo.titleAttribute = "name"; networkInfo.linkAttribute = "link"; clipAndShare.addNetwork(networkInfo);