Reputation: 31
<?php
require "src/facebook.php";
$facebook = new Facebook(array(
'appId'=>'xxxxxxxxx',
'secret'=>'xxxxxxxxxxxxxxxxx',
'cookie'=>true
));
if(!$facebook->getUser())
{
$url = $facebook->getLoginUrl(array('scope'=>'email,publish_actions'));
echo "<script> top.location=\"".$url."\"; </script>";
exit(0);
}
$params = array('article'=>'http://www.xxxxxxxxx.com/script/','access_token'=>$facebook->getAccessToken());
$out = $facebook->api('/me/namespace:read','post',$params);
print_r($out);
exit(0);
?>
But i got some questions, where should i put these meta tags? i only found javascript examples and i got another question how to use a dynamic url like:
http://www.xxxxxxxxx.com/script/?article_id=xxxx
if i try to put some parameter in this url it returns error like:
Fatal error: Uncaught OAuthException: (#3502) Object at URL http://www.xxxxxxxxx.com/script/?article_id=xxxx has og:type of 'website'. The property 'article' requires an object of og:type 'namespace:article'. thrown in xxxxxxx on line 1106
thanks.
Upvotes: 1
Views: 3901
Reputation: 1011
Within the <head> section of http://www.xxxxxxxxx.com/script/?article_id=xxxx you should add something like this:
<head>
<title>My article</title>
<meta property="og:title" content="My article" />
<meta property="og:type" content="namespace:article" />
<meta property="og:url" content="http://www.xxxxxxxxx.com/script/?article_id=xxxx" />
<meta property="og:image" content="http://www.xxxxxxxxx.com/image.jpg" />
<meta property="fb:app_id" content="xxxxxxxx" />
<meta property="og:description" content="My wonderful article" />
</head>
From the namespace in the error message I'm guessing that you defined your own article object and didn't use the builtin article object.
Upvotes: 1