Share on social media
Share a link on social media such as facebook, twitter..etc that leads to your wishlist.
swat.shareListSocial
This API creates the unique URL for a particular sharing platform and opens a new dialog in that platform to perform the sharing step. For eg., for facebook, the share page will be opened in a new window.
Definition
swat.shareListSocial(lid, fromName, platformShareUrlTemplate, platform, note, onError);
This API is only supported for Logged in Users.
The user must have a valid source email address, which is picked up implicitly by the API. The user must be logged in to use this functionality.
Example
let lid = "" // List ID you wish to share.
let fromName = "Name of the sharer";
let platformShareUrlTemplate = "https://www.facebook.com/sharer.php?u={{shareurl}}&t={{note}}"; // this is specific to platform, please look up your platform.
let platform = "facebook" // name of the platform
let note = "Note you want to add to share" // Optional note.
let onError = function(error) {
// Error is an xhrObject
console.log("There was an Error opening the share platform", error);
}
swat.shareListSocial(lid, fromName, platformShareUrlTemplate, platform, note, onError);
API Parameters
Argument | Type | Description |
---|---|---|
lid | guid | List id to share. Pass null if multiple lists is not enabled |
fromName | string | Sharer's name for reporting |
platformShareUrlTemplate | string | The social platform-specific share URL with Mustache tags. Out of the box, platforms supported are "facebook", "twitter". To get share urls for these, use the variable - swat.retailerSettings.Wishlist.SharingModes. This has the default icon url, share url and key for each of these platforms. Again, new platforms can be added here and/or default icons can be changed for you if you need |
platform | string | The key to one of the sharing platforms. By default, one of "facebook", "twitter" |
note | string | Some platforms allow to send a custom note along with shared url. This field is to capture that message. Amongst the defaults, at the moment, notes only work with twitter. |
onError | function | Function that gets called if there is an error. Called with error message as argument. |
Updated about 1 year ago