3

I am using the PHP SDK to post to the logged in users timeline using the facebook::api method. I am pretty sure I had it working in the past but now it seems to fail and return the following error:

OAuthException: (#3502) Object at URL http://example.com/ has og:type of 'website'. The property 'event' requires an object of og:type 'example:event'.

I have placed the URL into the Facebook debugger tool adn this returns fine. I have also used the Graph API explorer to test the POST request as well and this works. The only place it doesnt is from my PHP script.

I know I am not the only one who is experiencing this but it seems that everyone else is using the Javascript SDK so the solution is not relevant to me.

I have also tried setting scrape=true in my request but this makes no difference.

The code I am using is:

try{
    // Post the reply to the Facebook users wall
    $this->facebook_get_attendance['action_id'] = $this->facebook->api(
        "/me/example:reply?event=".urlencode("http://www.example.com/facebook-event/$this->area_rel/$this->facebook_event_reply_id")."&scrape=true&access_token={$this->facebook_user_details['access_token']}",
        "POST"
    );
    $this->facebook_get_attendance['action_id'] = $this->facebook_get_attendance['action_id']['id'];
}catch(FacebookApiException $e){
    error_log($e);
    $this->facebook_get_attendance['action_id'] = NULL;
}

Any ideas why this is happening?

The URL that is being passed is:

/me/example:reply?event=http%3A%2F%2Fwww.example.com%2Ffacebook-event%2Fbath%2F612&access_token=ACCESS_TOKEN
Ben Carey
  • 16,540
  • 19
  • 87
  • 169
  • How are you Post the reply to the Facebook users wall with `$this->facebook->api("/me/example:reply`? Check this [link](http://stackoverflow.com/questions/7570335/difficulty-posting-actions-to-timeline) – Somnath Muluk Feb 23 '12 at 05:56
  • Clearly you are unfamiliar with PHP objects, there is nothing wrong with the code! That link is specifically for the Javascript SDK. This is PHP! I have come to the conclusion that this is actually a bug as I have debugged it as much as I possible can through the PHP SDK and I still cannot get it to work. Facebook have also acknowledged that this is likely to be a bug and are looking into it, hopefully wont take them too long as this is obviously a pretty dire issue! – Ben Carey Feb 23 '12 at 06:11
  • check this out it may help you http://stackoverflow.com/questions/7570335/difficulty-posting-actions-to-timeline – Sam Arul Raj T Feb 28 '12 at 09:40
  • ...urlencode("http://www.example.com/facebook-event/$this->area_rel/$this->facebook_event_reply_id") is it possible to use object call [$this->facebook_event_reply_id] within double quotes directly? I never got it substitute value, I use to concat it. – Junaid Feb 28 '12 at 10:09
  • @SamArulRaj, I have seen this question and it is not relevant to this question as it refers to the javascript SDK. – Ben Carey Feb 28 '12 at 12:39
  • @Junaid, yes it is. The passed url is definitely correct. I believe the error is at Facebooks end. I have reported this as a bug – Ben Carey Feb 28 '12 at 12:40
  • @SamArulRaj I have read it thoroughly and the answer is not correct for this question. Although he receives the same error, the solution is not the same, my og:url is correct! – Ben Carey Feb 28 '12 at 14:47

2 Answers2

3

Most likely explanations based on previous experience:

  • You have an og:url tag on the event page, which redirects facebook somewhere else that doesn't have the event's OG tags
  • Your site is returning different content to the crawler than it gives to regular users (such as if the site needs a login) - debug this with a manual request: curl -i -H 'Accept: */*' -H 'Range: bytes=0-40960' -H 'Connection: close' -A 'facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)' $URL_GOES_HERE
Igy
  • 43,710
  • 8
  • 89
  • 115
  • Thank you very much for your reply, I will try this debug test now. The og:url on the page is the url of the page! So it is not redirecting it to a different address. Does that mean that in order to fix it I HAVE to remove the og:url meta tag? – Ben Carey Feb 23 '12 at 13:05
  • The same output Facebook is receiving when scraping your URL - I usually strip out any lines without 'meta' in them - this can sanity check if Facebook's actually detecting what you think it is I'm assuming the og:type tag isn't actually set to website like the error message says, by the way – Igy Feb 23 '12 at 16:17
  • How can I strip out everything apart from the meta tags because at the moment I cannot scroll up enough to see the full page. Yes, the og:type is set to 'example:event' where example is my app. What is weird is that if I call the url using curl on my server, it works. The only place this does not work is in the PHP Facebook SDK. I ahev debugged this and so far have not found what is causing it. – Ben Carey Feb 23 '12 at 16:39
  • According to this, it sees the webpage absolutely fine. All the tags are correct – Ben Carey Feb 23 '12 at 16:46
  • Without knowing the website and app there's not much else I can think of at this point - the error you're seeing in the debug tool might be incorrect :/ – Igy Feb 23 '12 at 18:15
  • As I am sure you can understand, I cannot publish the address of this website on here, however, if we initiate a chat session then I would be willing to give you some more info. – Ben Carey Feb 23 '12 at 21:17
  • The curl command that you posted was very helpful, but none of the above actually solved my problem. It turns out it is a bug with the PHP SDK. Please see my accepted answer – Ben Carey Jun 27 '12 at 06:51
0

I have reported this as a bug with Facebook and it is currently in the 'triaged' stage. If and when I have any updates, I will post them here.

Ben Carey
  • 16,540
  • 19
  • 87
  • 169