Facebook Share Dialog Borked!

Checked your games with Facebook integration lately? Noticed how they no longer share the title and descriptions that you so beautifully crafted?

Ok, there seem to have been some changes over at Facebook to the share dialog from what I understand you can no longer specify the contentTitle / contentDescription of the post being shared when you share a link, instead it is populated with Facebook scraped data. This is quite devastating for game developers that would like to share a custom story of the player doing something cool in their game. There does appear to be a way around it however, the link that you supply to the Facebook dialog is scraped by Facebook and any open graph tags (OG tags) are read and used to describe the content in the Facebook share dialog. Now using a simple server script we can generate a page with the tags in based on data passed to the URL via GET. A simple such script would look something like this:

[sourcecode language=”php”]
<!DOCTYPE html>
<html>
<head>
<meta charset=’utf-8′>
<meta property="og:type" content="article" />
<?php

$title = $_GET["t"];
$description = $_GET["d"];
$icon = $_GET["i"];
$title = htmlspecialchars($title);
$description = htmlspecialchars($description);
$icon = htmlspecialchars($icon);

echo " <meta property=’og:title’ content=’" . $title . "’ />\n";
echo " <meta property=’og:description’ content=’" . $description ."’ />\n";
echo " <meta property=’og:image’ content=’" . $icon . "’ />\n";
?>
</head>
<body>
</body>
</html>
[/sourcecode]

You would obviously need to work this into some type of landing page or the page your user will be redirected to when they click the link in the shared post will be blank!

Leave a Reply