Search code examples
phpfacebookcakephpmeta-tags

Facebook og meta tags - scraper fetches nothing


So I have this cakephp project, when I share the link to facebook i don't get og:description, og:image etc, even though everything seems to be there.

My code: (Views/Layouts/default.ctp)

<head>
...
<meta property="og:url" content="<?=Configure::read('og_url');?>landing" />
<meta property="og:title" content="<?=Configure::read('app_title');?>" />
<meta property="og:description" content="<?=Configure::read('og_description');?>" />
<meta property="og:image" content="<?=Configure::read('og_image');?>" />
...
</head>

I initialize everything in bootsrap.php so all my files can have access to these values.

Which produces this, View Page Source:

<head>
...
<meta property="og:url" content="https://www.philippidescompetition.com/landing" />
<meta property="og:title" content="Back To School Spin & Win! " />
<meta property="og:description" content="Συμπλήρωσε τα στοιχεία σου και παίξε "Spin & Win"!" />
<meta property="og:image" content="https://www.philippidescompetition.com/img/wheel/og_image_s.jpg" />
...
</head>

So far so good, but when I share the link on facebook I don't get any of the meta data. I tried the debugger tool, but it didn't really help.

I want to share philippidescompetition.com/landing this link, which redirects to the facebook app page or to the actual url philippidescompetition.com/users/register on my server, according to if its from a desktop or mobile, so am thinking this redirect causes the issue, but if I share philippidescompetition.com/users/register which doesn't have a redirect, all meta data are still empty

Any ideas?


Solution

  • You need to add an exception to your automatic redirect for the Facebook scraper.

    It can be recognized by its User-Agent, see https://developers.facebook.com/docs/plugins/faqs#faq_1748179212062572