Elemenofi
Elemenofi

Reputation: 374

Dynamic php og meta tags cant be accessed by facebook?

<html lang="en">
  <head>
    <?php
      $th = $_GET['th'];
    ?>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <meta property="og:title" content="Test"/>
    <meta property="og:type" content="website"/>
    <meta property="og:url" content="http://www.rapsodia.com/ar/admin/shares.php "/>
    <meta property="og:site_name" content="Rapsodia Verano 15'"/>
    <meta property="og:description" content="Test"/>
    <meta property="og:image" content="http://www.rapsodia.com/ar/img/lookbook/<?php print $th; ?> "/>

    <title>Rapsodia 2015</title>    

  </head>
  <body>

    <img src="http://www.rapsodia.com/ar/img/lookbook/<?php echo $th; ?>">

  </body>
</html>

If I enter this:

http://www.rapsodia.com/ar/admin/shares.php?th=09.jpg

at

https://developers.facebook.com/tools/debug/og/object/

I get

<meta property="og:title" content="Test" />
<meta property="og:type" content="website" />
<meta property="og:url" content="http://www.rapsodia.com/ar/admin/shares.php " />
<meta property="og:site_name" content="Rapsodia Verano 15&#039;" />
<meta property="og:description" content="Test" />
<meta property="og:image" content="http://www.rapsodia.com/ar/img/lookbook/ " />

for some reason the php variable is not making its way in to the facebook server :(

If I go to http://www.rapsodia.com/ar/admin/shares.php?th=09.jpg

manually everything works just fine :(


How can I make this work? I really dont know what else to try. I really must have dynamic og tags or else I will probably get fired or something.

Upvotes: 0

Views: 1015

Answers (1)

Elemenofi
Elemenofi

Reputation: 374

<html lang="en">
  <head>
    <?php
      $th = $_GET['th'];
    ?>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <meta property="og:title" content="Test"/>
    <meta property="og:type" content="website"/>
    <meta property="og:url" content="http://www.rapsodia.com/ar/admin/shares.php?th=<?php print $th; ?>  "/>
    <meta property="og:site_name" content="Rapsodia Verano 15'"/>
    <meta property="og:description" content="Test"/>
    <meta property="og:image" content="http://www.rapsodia.com/ar/img/lookbook/<?php print $th; ?> "/>

    <title>Rapsodia 2015</title>    

  </head>
  <body>

    <img src="http://www.rapsodia.com/ar/img/lookbook/<?php echo $th; ?>">

  </body>
</html>

As WizKid pointed out, I had to also include the parameters in the og:url and it works!

Upvotes: 1

Related Questions