I have a Joomla-page (v3.2.4) where I put in some dynamic Open Graph tags with PHP, like this:
The PHP, before the tag:
$getcid = JRequest::getVar('id');
if(!isset($getcid)) {
$title = "LIVA Kurser";
$description = "Danmarks største udbyder af kurser til såvel offentlige og erhverv samt private.";
$image = "http://www.livakursertestsite.dk/images/liva-logo.jpg";
$type = "website";
} else {
$db = JFactory::getDbo();
$user = JFactory::getUser();
$query = $db->getQuery(true);
$ogquery = "SELECT DISTINCT * FROM jos_managecourse WHERE state = '1' AND id = '".$getcid."' LIMIT 1";
$db->setQuery($ogquery);
$db->query();
$getcourse = $db->loadObjectList();
$description = substr(strip_tags($getcourse[0]->details), 0, 247);
$title = $getcourse[0]->course_name;
$description = preg_replace( "/\r|\n/", "", $description );
$description = str_replace( " ", " ", $description );
$image = JURI::root()."administrator/components/com_managecourse/images/".$getcourse[0]->image_url;
$type = "article";
}
And in my tag I have this:
<!-- Facebook Open Graph -->
<meta property="fb:app_id" content="502033806595590" />
<meta property="og:site_name" content="LIVA Kurser" />
<meta property="og:type" content="<?php echo $type; ?>" />
<meta property="og:title" content="<?php echo $title; ?>" />
<meta property="og:url" content="<?php echo JURI::current(); ?>" />
<meta property="og:image" content="<?php echo $image; ?>" />
<meta property="og:description" content="<?php echo $description; ?>..." />
<!-- End Facebook Open Graph -->
When I run the page through the Facebook Object Debugger, I get the following two errors:
Object at URL 'http://www.livakursertestsite.dk/kurser/babytegn-2' of type 'website' is invalid because a required property 'og:title' of type 'string' was not provided.
And the second error:
Curl Error : BAD_CONTENT_ENCODING Error while processing content unencoding: invalid block type
I have tried:
- Moving the code below and above the title-tag
- Moving it to the very top and very bottom of the head-tag, but neither works.
- Putting the PHP-code in the head-tag, but still nothing.
You can see the site here: http://www.livakursertestsite.dk/kurser/babytegn-2
EDIT:
I have removed the PHP-code from the tags, so they are no longer dynamic, to see if that was the cause, but it wasn't. Now the code looks like this:
<meta property="og:locale" content="da_DK" />
<meta property="og:type" content="website" />
<meta property="og:title" content="LIVA Kurser" />
<meta property="og:description" content="Beskrivelse..." />
<meta property="og:url" content="http://www.livakursertestsite.dk/kurser" />
<meta property="og:image" content="http://www.livakursertestsite.dk/images/liva-logo.jpg" />
<meta property="fb:app_id" content="502033806595590" />
<meta property="og:site_name" content="LIVA Kurser" />
I have now also tried:
- Testing the site on Googles Rich Snippets testing tool, and Google gets all the data.
- Removing all not-obligatory Open Graph-tags, so only the four obligatory tags (type, title, url and image) was present.
- Removing all javascript which caused errors in Firebug.
And the Facebook Debugger still can't get the data.
Edit #2:
After the comment by @CBroe I fixed the page, so it could be validated, with no errors, but still no luck.