I want to allow a user of my web-app to be able to post multiple objects to their timeline from one page (main_page).
I already have the user's access token stored.
Tags on page I am trying to submit, the url is page_url:
<meta property="fb:app_id" content="my_app_id" />
<meta property="og:type" content="my_namespace:my_object" />
<meta property="og:title" content="some string" />
<meta property="og:description" content="some other string" />
<meta property="og:image" content="some_image_url" />
<meta property="og:locale" content="en_US" />
<meta property="og:url" content="page_url" />
Rails code to submit the url, triggered from main_page:
begin
fb_post = RestClient.post 'https://graph.facebook.com/me/my_namespace:do', :access_token=>user.get_facebook_auth_token, :my_object=>"page_url"
rescue StandardError => e
p 'e.response is'
p e.response
end
Output
2011-11-02T02:42:14+00:00 app[web.1]: "e.response is"
2011-11-02T02:42:14+00:00 app[web.1]: "{\"error\":{\"message\":\"(#3502) Object at URL page_url has og:type of 'website'. The property 'my_object' requires an object of og:type 'my_namespace:my_object'.\",\"type\":\"OAuthException\"}}"
The really weird thing is that, after getting this error, if I test the page_url on the Object Debugger, it passes without any errors/warnings, the og:type
is the correct type and note 'website'
, and then running the same Rails code as above will work fine.
I have tried it without the og:url
tag and the same thing happens.
UPDATE:
As per Igy's answer, I tried seperating the object scraping process from the action creating process. So, before the action was submitted for a brand new object, I ran an update on a the object, with scrape=true
.
begin
p 'doing fb_update'
fb_update = RestClient.post 'https://graph.facebook.com', :id=>page_url, :scrape => true
p 'fb_update is'
p fb_update
rescue StandardError => e
p 'e.response is'
p e.response
end
Output
2011-11-05T13:27:40+00:00 app[web.1]: "doing fb_update"
2011-11-05T13:27:50+00:00 app[web.1]: "fb_update is"
2011-11-05T13:27:50+00:00 app[web.1]: "{\"url\":\page_url,\"type\":\"website\",\"title\":\page_url,\"updated_time\":\"2011-11-05T13:27:50+0000\",\"id\":\id_here}"
The odd thing is that the type is website
, and the title is the page's url. Again, I have checked both in the HTML and the Facebook debugger, and the type and title are both correct in those.