Skip to content
Advertisement

how to solve double quotes issue in facebook og title property

I have a simple open graph functionality on my facebook app and I post some dynamic text on facebook. Here is my code:

<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# APP: http://ogp.me/ns/fb/APP#">
  <meta property="fb:app_id"      content="00000000000000" /> 
  <meta property="og:type"        content="XXX:XXX" /> 
  <meta property="og:url"         content="http://example.com" /> 
  <meta property="og:title"       content="<?php echo $_GET['title']; ?>" />
  <meta property="og:description" content=" " /> 
  <meta property="og:image"       content="<?php echo $_GET['image']; ?>" />

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

The problem is that when there are double quotes inside $_GET[‘title’] variable only the part before that quote is sent to facebook. I know why this happens but can’t think of any solution to this problem. Any ideas?

Advertisement

Answer

<?php echo htmlentities($_GET['title'], ENT_QUOTES); ?> should work?

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement