I got exception when I try to publish action to facebook.
Exception :
{"error":{"message":"(#3502) Object at URL localhost/XXX has og:type of 'website'. The property 'myobject' requires an object of og:type 'mynamespace:myobject'. ","type":"OAuthException","code":3502}}
FB.api(
'/me/mynamespace:myaction',
'post',
{ myobject: url,
access_token: accessToken
},
function (response) {
if (!response || response.error) {
Alert(JSON.stringify(response));
}
});
My Url Generated from a model from backend:
My Url : http://localhost/post/og/
public ActionResult og(int id)
{
return View(new OGModel(id));
}
View :
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"
xmlns:fb="https://www.facebook.com/2008/fbml">
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# @Model.NameSpace: http://ogp.me/ns/fb/@Model.NameSpace#">
<title>@Model.Title</title>
<meta property="fb:app_id" content="@Model.AppId" />
<meta property="og:type" content="@Model.NameSpace:myobject" />
<meta property="og:url" content="@Model.SharingLink">
<meta property="og:title" content="@Model.Title" />
<meta property="og:image" content="@Model.Image" />
</head>
<body>
<div>
</div>
</body>
</html>
Any idea?
You can’t post OG actions where the object URLs are on localhost because Facebook’s crawler won’t be able to reach them and read the meta tags.
The URL of all your objects needs to be accessible from the internet; specifically by Facebook’s crawler.
You can check what, if anything, Facebook detects on your URL by using Facebook’s Debug Tool