1

I'm trying to put Facebook "Share" buttons on various elements on a one-page Bootstrap ASP.NET MVC page. When each button is clicked, it would display a different image, summary, and URL for that element on the page. The URL will send the user to a specific tag on the page, or display a blog post; so, even though this is a single-page design, the URL, summary, images will be different for different elements.

Facebook no longer supports the old method of passing that information on the URL to its sharer.php, but uses the new Open Graph og:parametername meta tags to fetch the necessary information. However, as I require a different image, summary, etc., for each "Share" button, this og:... technique outlined in this SO answer won't work.

I've found some documentation on this site about using the Facebook SDK for Web Developers, but its examples aren't addressing what I'm trying to do. Is it even possible to do what I'm describing?

Thanks.

Community
  • 1
  • 1
Alex
  • 34,699
  • 13
  • 75
  • 158

1 Answers1

2

You'll have to create a redirecting page that will hold all the correct FB og: fields.

You can pass all the values into a generic view to setup the og: fields, then in the body of the view use Javascript to redirect them to the content you really want them to see.

<script> location.href = 'http://example.com/the_real_page'; </script>
Kaizen Programmer
  • 3,798
  • 1
  • 14
  • 30
  • Thanks, @Michael_B. Not sure what you mean by "in the body of the view use Javascript to redirect them to the content you really want them to see". Do you mean that the view would be a popup? – Alex Jun 09 '15 at 14:19
  • 1
    I was referring to the html ``, the javascript will actually perform a page redirect. Facebook's crawler does not 'see' javascript, it just looks at the `og:` fields when creating the shared link. – Kaizen Programmer Jun 09 '15 at 14:25
  • OK, thanks. But wouldn't the redirect be kind of annoying to users? I know it's really the only way to do what I'm talking about, but it's unfortunate that Facebook doesn't allow the old way of doing this for these specific instances. I guess it could also be done via an `iframe` that loads the view with its own `og` fields. – Alex Jun 09 '15 at 14:28
  • 1
    The redirect will be imperceptible to the average user. I wouldn't worry about it too much. They are only looking at the title, description and image on FB. – Kaizen Programmer Jun 09 '15 at 14:31