Facebook share for browser extensions
While trying to use Facebook JavaScript SDK I'm getting error 'Can't Load URL: The domain of this URL isn't included in the app's domains…'.
HTML
<button id="share-fb">
Share on facebook
</button>
JavaScript
document.querySelector('#share-fb').addEventListener(
'click',
function () {
shareOnFacebook(
'https://chrome.google.com/webstore/detail/google-hangouts/nckgahadagoaajjgafhacjanaoiihapd',
'Google Hangouts',
'Hangouts brings conversations to life with photos, emoji, and even group video calls for free.',
'Hangouts Team',
'https://i.ytimg.com/vi/nZOYwpONhIQ/maxresdefault.jpg'
)
}
)
function shareOnFacebook(url, title, desc, caption, imageUrl) {
window.open(
getSharingUrl(url, title, desc, caption, imageUrl)
)
}
function getSharingUrl(url, title, desc, caption, imageUrl) {
let uri = `?u=${encodeURIComponent(url)}`
+ `&title=${encodeURIComponent(title)}`
+ `&description=${encodeURIComponent(desc)}`
+ `&caption=${encodeURIComponent(caption)}`
+ `&picture=${encodeURIComponent(imageUrl)}`
return 'https://www.facebook.com/sharer/sharer.php' + uri + '&mode=group'
}