After sharing a URL in Facebook, in order to generate nice-looking previews, Facebook scans the document for open graph meta tags. i.e
<meta property="og:url" content="http://www.nytimes.com/2015/02/19/arts/international/when-great-minds-dont-think-alike.html" /> <meta property="og:type" content="article" /> <meta property="og:title" content="When Great Minds Don’t Think Alike" /> <meta property="og:description" content="How much does culture influence creative thinking?" /> <meta property="og:image" content="http://static01.nyt.com/images/2015/02/19/arts/international/19iht-btnumbers19A/19iht-btnumbers19A-facebookJumbo-v2.jpg" />
Normally these would go in Default.html, but they would be static. But is it possible to create dynamic meta tags in the WiseJ document, based on URL parameters?
I have a method in one of my forms that gets called after passing in URL parameters, if there was a way to do something like
Document.Inject(“custom HTML meta tags here”)
that could possibly work.
Ideally, Facebook would allow these set as parameters into sharer.php , but it appears that is deprecated and no longer works. So right now I’m just wondering if dynamic META tags are possible in WiseJ.
Which is possible also with Wisej. It’s enough to use an aspx pages instead of an html page and change the meta tags using aspx inline tags. Something like this:
I have attached a sample application that can share 3 options of the same URL.
I suppose one workaround would be:
I’m trying the 2nd method without luck. I placed it first in the form’s method, and even moved it right up to Main() in Program.vb.
With breakpoints set, I’m not even seeing it get hit by Facebook. (Even after forcing a refresh by clicking on “Refresh Share Attachment”)
‘attempt to inject meta tag
Dim strDesc As String = Chr(34) + “View issue ” + intIssueToLoad.ToString + Chr(34)
Application.Eval(“$(‘head’).append(‘<meta property=””og:description”” content=” + strDesc + “>’);”
Perhaps the Meta tags are being used by Facebook before the body is even parsed, and WiseJ loaded. When the tags are present in Default.html, they do alter the preview of the share attachment.
Basically it’s exactly the same as any web system would have to do. Wisej gives the additional possibility of processing the request on the server first and calling the client from the server.