B
B
Briss2014-03-13 15:05:49
Facebook
Briss, 2014-03-13 15:05:49

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

Where acc. titlefrompage - title of the block, description - text of the block, addresstoimage.jpg - link to the image.
But for some reason it doesn’t work, a standard Facebook pop-up opens, with the page data, not the block data, although the data in the link is correct.
As far as I understand, Facebook released new share buttons, and now sharer.php works somehow differently than before.
I tried to insert open-graph meta tags into the page when clicking on the button so that it parses them, and there is 0 attention to this.
For sharing, I use the following code (by the way, from one of the articles from Habr):
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)

        }));

Everything is perfect for vk and twitter, but facebook doesn't work
:(

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ilya Shabanov, 2014-03-13
@ishaba

stackoverflow.com/questions/1211223/multiple-share...

C
Comport, 2014-05-27
@Comport

Goodnight! I also asked myself this question, what did you end up with? What way zayuzali?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question