Skip to content

Instantly share code, notes, and snippets.

@felquis
Last active December 26, 2015 18:58
Show Gist options
  • Save felquis/7197764 to your computer and use it in GitHub Desktop.
Save felquis/7197764 to your computer and use it in GitHub Desktop.
Retorna uma URL para compartilhamento de conteúdo no Facebook.
var url = shareURL({
url: 'http://felquis.com/',
image: 'http://felquis.com/img/posts/ilusao-de-muller-lyer.jpg',
title: 'Titulo que você quiser',
summary: 'Descrição que você quiser'
})
var shareURL = function (obj) {
var url = 'https://www.facebook.com/sharer/sharer.php?s=100&p[url]='
url += encodeURIComponent(obj.url)
if (!!obj.image) {
url += '&p[images][0]=' + encodeURIComponent(obj.image)
}
if (!!obj.title) {
url += '&p[title]=' + encodeURIComponent(obj.title)
}
if (!!obj.summary) {
url += '&p[summary]=' + encodeURIComponent(obj.summary)
}
return url
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment