1

I use following sourcecode to share a Feed on Facebook.

Explanation: I have many pictures and each picture has a own ShareButton with an onclick which starts the shareonfb(). And the first share works very well, it shares the picture, but if somebody clicks onto the share, it's opens the gallery which consist the picture(because, if i use for 'link' the direct picture-url, it would only open the picture and the person would not see the homepage).

Problem: If i try to reshare(to click on the share button in facebook at this share), facebook doesn't use the content of this variables. It uses the og:XXXX meta-tags which are at my website(where it goes by the 'link' url). Because of that, there is a other Picture and Text ...(the share-content has changed).

So, I don't understand why it does that ... I can only specify the datas/variables for 1 post/share ... that makes no sense. Then I could work directly with the og:xxx meta-tags. BUT I don't want that, because the pictures itself has no own html-page where i could place my own meta-tags(i show them "directly"(with fancybox). (I wanted to change the meta-tags by javascript, but I read here on stackoverflow that the facebook crawler doesn't run JS.) So, for what is the function to specific this datas?, and how get I Facebook to don't change it?

MfG Torben K

function shareonfb() {
    var FB_ui_var = {   
        fb_method : 'feed',
        fb_name : 'Name of picture',
        fb_link : 'http://mysite.de/the_gallery_which_consist_the_picture027.html',
        fb_caption : 'Description caption',
        fb_picture : 'http://mysite.de/picture027.jpg',
        fb_description : 'Descriton Text',           
    }

    FB.ui({
     method: FB_ui_var.fb_method,
     name: FB_ui_var.fb_name,
     link: FB_ui_var.fb_link,
     caption: FB_ui_var.fb_caption,
     picture: FB_ui_var.fb_picture,
     description: FB_ui_var.fb_description,     
    }, function(response){});
}
Alex
  • 467
  • 4
  • 13
Torben
  • 23
  • 4

1 Answers1

0

That´s how it is, the share dialog does not allow dynamic content (anymore), you ALWAYS need a page with Open Graph tags and the dialog only takes the URL as parameter.

One way to solve this is to use a PHP file with a parameter/id for getting separate Open Graph tags and a JavaScript redirection to the main page. The Facebook crawler does not run JavaScript, so it can get the Open Graph tags.

Btw, the feed dialog is deprecated, you should use the FB.ui share dialog instead.

andyrandy
  • 72,880
  • 8
  • 113
  • 130
  • Thx for quick response. K, i think i got it and found this PHP: http://stackoverflow.com/questions/12404868/changing-the-value-of-ogimage-with-jquery-click I saw that before to, but until now i dont know about php and I thought it should be possible with this function, so I still dont understand where this function(the FB.ui.picture var) is good for ... – Torben Nov 15 '14 at 01:42
  • yeah, that other threads tells you exactly the same as my answer :) – andyrandy Nov 15 '14 at 09:42
  • K. But i dont understand what i see there, or better how that should work(generelly(not the programming)). In that resolution is a click which change dynamicly the og:image. (I do the same with the FB.ui.picture and that works for the first post/share too). BUT how i understand it until now, if there is a reshare Facebook will look for the og:image tag of the site from the given url ... and then there is for that resolution no click. So how will Facebook get then the right og:image for resharing??? – Torben Nov 15 '14 at 16:26
  • you don't dynamically change it, you generate it on the server, depending on a get variable (somefile.php?image=2). – andyrandy Nov 15 '14 at 16:29
  • KK. I will start a try with that. I have found a good resolution based on what u said. ---- For next readers, I have found this explenation: http://stackoverflow.com/questions/9504176/can-facebook-open-graph-objects-be-created-dynamically which links to this resolution i will try: http://stackoverflow.com/questions/8431694/generating-facebook-open-graph-meta-tags-dynamically – Torben Nov 15 '14 at 16:52
  • K ... then im done here. But the question itself is not answered. Maybe the answer is that the FB.ui.picture - atribute is an old think ... which works in the past. But in dont know ... – Torben Nov 15 '14 at 19:12
  • the feed dialog is deprecated as a whole, you should not use it at all anymore. – andyrandy Nov 15 '14 at 19:17
  • so the answer to your question is in my answer up there. no dynamic content is allowed anymore. use fb.ui share now and only use the url as parameter. – andyrandy Nov 15 '14 at 19:19