3
votes

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:

  1. I have the correct app id.

  2. When I use the curl command supplied by facebook for the action, it posts fine.

  3. My head and meta tags are exactly what I copied from the object "code" that facebook supplies.

Thanks in advance!

1
@JeffSherlock This would be an example of the url of the page that contains a photo that someone would love stage.lover.ly/image/78528christ0pherl
So I believe that the real solution here is to remember that when testing with localhost, facebook cannot scrape the page, so it defaults to og:type of website - hence why I was seeing this on my local project. As for why it is happening on my staging server, I am still looking into that.christ0pherl
Did you get to the bottom of this? Is it a caching issue at Facebook? I'm have the same issue and haven't solved yet.Raoot
Somehow facebook posted an article about this 'bug' but as you say, we already do it like in this article and the bug still occurs: developers.facebook.com/blog/post/612Jurik

1 Answers

0
votes

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);