So I'm making an iPhone app that involve sharing through Facebook open graph protocol.However I'm stuck while creating a dynamic webpage for the object with meta tag. I came across this post, Generating Facebook Open Graph meta tags dynamically, and tried using the code, but it doesn't work.
This is my food.php object webpage.
<?php
$params = array();
if(count($_GET) > 0) {
$params = $_GET;
} else {
$params = $_POST;
}
// defaults
if($params['type'] == "") $params['type'] = "food";
if($params['title'] == "") $params['title'] = "default title";
if($params['image'] == "") $params['image'] = "blank";
if($params['description'] == "") $params['description'] = "default description";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# MY_APP_NAME_SPACE: http://ogp.me/ns/fb/MY_APP_NAME_SPACE#">
<!-- Open Graph meta tags -->
<meta property="fb:app_id" content="MY_APP_ID" />
<meta property="og:url" content="http://mysite.com/index.php?type=<?php echo $params['type']; ?>&title=<?php echo $params['title']; ?>&image=<?php echo $params['image']; ?>&description=<?php echo $params['description']; ?>"/>
<meta property="og:type" content="MY_APP_NAME_SPACE:<?php echo $params['type']; ?>"/>
<meta property="og:title" content="<?php echo $params['title']; ?>"/>
<meta property="og:image" content="http://mysite.com/img/<?php echo $params['image']; ?>.jpg"/>
<meta property="og:description" content="<?php echo $params['description']; ?>"/>
</head>
</html>
With this code reside in my server, I tried access the page using fb object debugger tool with this url.
http://mysite.com/food.php?fb:app_id=MY_APP_ID
&og:type=MY_APP_NAME_SPACE:food
&og:title=Pizza
&og:description="Pizza"
&og:image=http://mysite.com/img/someImage.jpg
*note there is no space in the url
and the debugger throws this error
Error Parsing URL:Error parsing input URL, no data was scraped.
I suppose the problem lies in the url that I entered because the tool cannot parse it?If not what could it be?
http://...?type=...&title=...
and so on, alsoapp_id
is not parameterized in your pasted code. – complex857/
or ':` doesn't allowed in query string. See what rawurlencode prints for your individual GET parameters. – complex857