Answer the question
In order to leave comments, you need to log in
Share button for Facebook. How to send custom data?
There is a site, it has a page, which can have N blocks containing: title, text, picture, "Share" buttons for social networks.
For Facebook, data is parsed directly from the blocks, and a link of the form
https://www.facebook.com/sharer/sharer.php?&p[title]=titlefrompage&p[summary]=description&p[url]=link&p[images][0]=addresstoimage.jpg
Share = {
facebook: function(purl, ptitle, pimg, text) {
url = 'https://www.facebook.com/sharer/sharer.php?';
url += '&p[title]=' + encodeURIComponent(ptitle);
url += '&p[summary]=' + encodeURIComponent(text);
url += '&p[url]=' + encodeURIComponent(purl);
url += '&p[images][0]=' + encodeURIComponent(pimg);
url += '?v3';
Share.popup(url);
},
popup: function(url) {
window.open(url,'','toolbar=0,status=0,width=626,height=436');
}
};
$(document).on('click','.social-icons-block a .fb',(function(){
var title = ($(this).parents('.cont-block').find('.cont-block_title').text());
var text = ($(this).parents('.cont-block').find('.cont-block_text').text());
var pimg = ($(this).parents('.cont-block').find('.cont-block_gallery img').attr('src'));
var purl = (document.location.href);
pimg= ('site.ru') + pimg;
console.log(title+ text + pimg + purl);
Share.facebook(purl,title,pimg,text)
}));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question