1

This is my dynamic title and meta description update code;

$titlecek=mysql_query("SELECT bahisisim,bahisiaciklama,URL FROM bahis WHERE id='$bahisid'");
$titlecekx=mysql_fetch_array($titlecek);
echo "<title>" . mb_strtolower($titlecekx[0],'UTF-8') . "</title>";
echo '<META NAME="Description" CONTENT="' . mb_strtolower($titlecekx[1],'UTF-8') . '">';

But when I try to share my page at Facebook it looks like;

http://666kb.com/i/c6st3ke4u4hqaem42.gif

By the way its HTML codes are like these at output;

<title>bu bahise gelen evet says tek say olacak</title><META NAME="Description" CONTENT="bu bahise 2 gün içerisinde gelen evet oyu sayısı tek sayı olacak. (ilkokullu editi: 2'nin katları çift sayıdır, 0 çift sayıdır)">

How can I solve this issue?

Slavez
  • 229
  • 2
  • 3
  • 12

3 Answers3

3

Every time you change your meta tags, you'll have to run your URL through the Facebook Debugger to make sure that Facebook discards it's cached version of your meta tags.

Taken from the Facebook Open Graph Protocol documentation, under the "Editing Meta Tags" section -

For the changes to be reflected on Facebook, you must force your page to be scraped. The page is scraped when an admin for the page clicks the Like button or when the URL is entered into the Facebook URL Linter Debugger.

Lix
  • 47,311
  • 12
  • 103
  • 131
  • 1
    The cache will expire in like 24 hours if you don't use the debugger, too. – ceejayoz Aug 29 '12 at 13:54
  • @cee - That's good to know too! Although when changing meta tags, one should usually test these things and not simply wait for the cache to expire... They gave us a great tool (the debugger) so we should utilize it :) – Lix Aug 29 '12 at 13:58
1

Make sure that you tell what character encoding the site uses. Without that, even if you correctly output the values in UTF-8 format, the consumer (in this case Facebook) will not know what encoding to use when reading your data.

One way to do that is using this:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

In HTML5, you can also say:

<meta charset="UTF-8" />
Community
  • 1
  • 1
kapa
  • 77,694
  • 21
  • 158
  • 175
0

Final solution;

$turkceler= array("ç", "ğ" , "ı", "ö", "ş", "ü");
$degistir= array("&#231", "&#287", "&#305", "&#246", "&#351", "&#252");
echo "<title>" . str_replace($turkceler,$degistir,mb_strtolower($titlecekx[0])) . "</title>";
echo '<META NAME="Description" property="og:description" CONTENT="' . substr(strip_tags(str_replace($turkceler,$degistir,mb_strtolower($titlecekx[1]))),0,200) . "..." . '">';
echo '<meta property="og:image" content="' . $titlecekx[2] . '"/>';
Slavez
  • 229
  • 2
  • 3
  • 12