arsduo / koala

A lightweight Facebook library supporting the Graph, Marketing, and Atlas APIs, realtime updates, test users, and OAuth.
http://developers.facebook.com/
MIT License
3.56k stars 468 forks source link

How to get object by URL? #338

Open dmilisic opened 10 years ago

dmilisic commented 10 years ago

Hi!

I couldn't find a way to get object from Facebook graph by URL. I tried

graph = Koala::Facebook::API.new
graph.get_object("http://example.com")

but got Koala::Facebook::AuthenticationError: type: OAuthException, code: 2500, message: Unknown path components: /example.com [HTTP 400]

Response from Facebook graph for http://graph.facebook.com/http://example.com is:

{
   "id": "http://example.com",
   "shares": 178617,
   "comments": 69567
}

Is there another way to do that in Koala?

arsduo commented 10 years ago

Hi @dmilisic,

Sorry about the late response. What you're looks right to me -- it might actually be an encoding issue in Koala. If you're still seeing this, can you add Koala::Utils.logger.level = Logger::DEBUG, and paste back the log response that you're getting? I can investigate from there, especially if you can point me to a public URL to test this with.

Best,

Alex

dmilisic commented 10 years ago

Hi Alex,

here is the stack trace:

graph.get_object("http://example.com")
D, [2014-02-11T11:40:45.058835 #10522] DEBUG -- : GET: /http://example.com params: {}
Koala::Facebook::AuthenticationError: type: OAuthException, code: 2500, message: Unknown path components: /example.com [HTTP 400]
    from /home/developer/.rvm/gems/ruby-2.1.0@test/gems/koala-1.6.0/lib/koala/api/graph_api.rb:470:in `block in graph_call'
    from /home/developer/.rvm/gems/ruby-2.1.0@test/gems/koala-1.6.0/lib/koala/api.rb:57:in `api'
    from /home/developer/.rvm/gems/ruby-2.1.0@test/gems/koala-1.6.0/lib/koala/api/graph_api.rb:468:in `graph_call'
    from /home/developer/.rvm/gems/ruby-2.1.0@test/gems/koala-1.6.0/lib/koala/api/graph_api.rb:58:in `get_object'

Danijel

RKushnir commented 9 years ago

@dmilisic you can do graph.get_object('', id: url)

alpracka commented 9 years ago

@RKushnir that helps, ty.

arsduo commented 7 years ago

That's pretty awkward. I'll keep this flagged as an open issue.

alepore commented 7 years ago

see https://developers.facebook.com/docs/graph-api/reference/v2.8/url/

arsduo commented 7 years ago

Cool, thanks, that's useful. This type of weird need fits the criteria for a convenience method, so I'll build one.

arty-ms commented 6 years ago

thank you very murch, it's exciting