Using the sharing service and UI via JavaScript:
Staging (Unstable):
<script>
window.ShareaholicBookmarklet = window.ShareaholicBookmarklet || [];
ShareaholicBookmarklet.push([
'share', {
service: 'facebook',
link: 'http://www.example.com',
title: 'test title',
summary: 'this is cool'
},
function (err) {
console.log('Sharing invoked ');
console.log(err);
}])
</script>
<script
type="text/javascript"
src="//d2062rwknz205x.cloudfront.net/v2/ShareaholicBookmarklet.js"
data-shr-debug="true"
data-shr-assetbase="//d2062rwknz205x.cloudfront.net/v2/"
data-shr-namespace="ShareaholicBookmarklet"
data-shr-entrypoint="shrMain.js">
</script>
Production:
<script>
window.ShareaholicBookmarklet = window.ShareaholicBookmarklet || [];
ShareaholicBookmarklet.push([
'share', {
service: 'facebook',
link: 'http://www.example.com',
title: 'test title',
summary: 'this is cool'
},
function (err) {
console.log('Sharing invoked ');
console.log(err);
}])
</script>
<script
type="text/javascript"
src="//dsms0mj1bbhn4.cloudfront.net/v2/ShareaholicBookmarklet.js"
data-shr-assetbase="//dsms0mj1bbhn4.cloudfront.net/v2/"
data-shr-namespace="ShareaholicBookmarklet"
data-shr-entrypoint="shrMain.js">
</script>
ShareaholicBookmarklet.push([
'share', {
service: 'all'
},
function onInvoked(err) {
// err is falsy if there was no error
}
]);
All of the fields in the command object are optional EXCEPT for service
. If
you do not specify the any of the other fields the SDK will do it's best to try
and scrape the required fields from the page.
service
- the service name you wish to share via orall
title
- the title of the itemlink
- link to the itemsummary
- summary text for the itemimage
- image to shareimages
- an array of images to shareshort_link
- shortened link to the itemmedia_link
- link to media to share,link_title
- title for the link being shared,source
- defaults toShareaholic
The api object returned in the success callback will give you the ability to subscribe to events generated by user interactions with the UI.
// subscribing to events
function onClose() {
console.log('modal was closed');
}
// subscribe
api.on('modal.close', onClose);
// unsubscribe
api.off('modal.close', onClose);
API methods:
on
: pass a topic and callback function for notifications on that topicoff
: pass a topic and the callback function used to subscribe
API topics:
modal.close
: the modal window has been closed