Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 730
King Julien Avatar asked Apr 10 '12 17:04

King Julien


1 Answers

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

like image 67
David Nguyen Avatar answered Sep 30 '22 01:09

David Nguyen