Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook Open Graph, required property 'og:title' of type 'string' was not provided

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.

like image 343
razemauze Avatar asked Aug 20 '14 13:08

razemauze


2 Answers

You might want to try to disable any sort of compression, for example GZIP compression in PHP. This helped me with a similar problem in a Joomla 3.3 website.

I had GZIP compression enabled and Facebook was unable to scrape my website. Disabling the GZIP compression solved that issue.

I have not figured out yet if it's a Joomla problem or a GZIP/PHP problem in general or a facebook scrape problem.

EDIT: With a share action, Facebook only reads the first 40k of your page. When GZIP is enabled, reading only the first 40k will give problems as it is unable to decompress the partial contents.

A better solution would be to disable GZIP only for sites like Facebook, LinkedIn, etc.

You can use the small plugin called gzip very friendly Control: http://extensions.joomla.org/extensions/core-enhancements/performance/site-performance/27725

Or use this codee https://github.com/dgt41/ (zip the xml and php file and you can install it as a plugin)

Please note: If you have JCH Optimize module installed on your site you will need to disable gzip compression offered by the plugin. All other options can remain activated without any problems, including a native Joomla gzip compression.

Cheers, Teeuwis

like image 167
Teeuwis Hillebrand Avatar answered Nov 14 '22 21:11

Teeuwis Hillebrand


I found a solution for the problem in joomla 3 modifying only 2 files form joomla core so you don't have to turn off the GZIP option. It's turn off automaticaly only when detect the facebook crawler.

https://github.com/dgt41/joomla-cms/commit/6eef42e50e3f3e4c78c93285de7f9ecfe8bbfbf5 and a plugin to solve the problem but this one don't run ok to me.

https://github.com/dgt41/facebookfix/commit/e1d5aa3a1a94f7751d3b69db78ba1aa02dfc37c6

like image 45
user3848565 Avatar answered Nov 14 '22 23:11

user3848565