I am trying to add a custom action and object to my website with og. As stated in previous questions I searched through, the debugger scrapes the website properly and confirms that it is they way it should be without any errors, warnings, or exceptions.
However, when I post to that object with the php sdk, I am getting this exception from FB:
OAuthException: (#3502) Object at URL //mypage.com/image/details has og:type of 'website'. The property 'photo' requires an object of og:type 'app_prod:photo'.
[note I have removed all "http://" so that stackoverflow would not render them as links]
The php sdk call:
$ret_obj = $facebook->api('/me/app_prod:love', 'POST', array(
'photo' => '//mypage.com/image/details',
'access_token' => $token ));
The head of the page looks like this:
<head prefix="og: //ogp.me/ns# fb: //ogp.me/ns/fb# app_prod: //ogp.me/ns/fb/app_prod#">
<meta property="fb:app_id" content="APP_ID">
<meta property="og:type" content="app_prod:photo">
<meta property="og:url" content="http://mypage.com/image/details">
<meta property="og:title" content="A Picture I love">
<meta property="og:image" content="http://images.mypage.com/8f9117301e00dbfb.jpg">
<meta property="og:description" content="Here is a description">
Things I've double checked:
I have the correct app id.
When I use the curl command supplied by facebook for the action, it posts fine.
My head and meta tags are exactly what I copied from the object "code" that facebook supplies.
Thanks in advance!
I found a solution here and on Stackoverflow here.
The problem is usually caused by a server race condition – the application’s inability to handle two simultaneous HTTP requests. Sometimes when a user performs an action and the application calls a FB open graph request right away, chances are the new object page hasn’t been generated yet.
var openGraphUrl = '/me/' + OG_NAMESPACE + ':' + OG_ACTION + '?' + OG_OBJECT + '=' + siteURL;
var scrapeUrl = '/?ids='+siteURL+'&scrape=true';
_.setTimeout(function(){
FB.api(scrapeUrl, 'post',
function(response) {
if (!response || response.error) {
console.log('scrap: '+response.error.message);
} else {
FB.api(openGraphUrl, 'post',
function(response) {
if (!response || response.error) {
console.log('OG: '+response.error.message);
} else {
console.log('Successful! Action ID: ' + response.id);
}
}
);
}
});
}
, 5000);