koala icon indicating copy to clipboard operation
koala copied to clipboard

How to get object by URL?

Open dmilisic opened this issue 12 years ago • 8 comments

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?

dmilisic avatar Nov 19 '13 13:11 dmilisic

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

arsduo avatar Feb 02 '14 17:02 arsduo

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

dmilisic avatar Feb 11 '14 10:02 dmilisic

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

RKushnir avatar Apr 29 '15 08:04 RKushnir

@RKushnir that helps, ty.

alpracka avatar Jun 01 '15 13:06 alpracka

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

arsduo avatar Feb 17 '17 04:02 arsduo

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

alepore avatar Feb 20 '17 17:02 alepore

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

arsduo avatar Feb 20 '17 17:02 arsduo

thank you very murch, it's exciting

arty-ms avatar Feb 06 '18 20:02 arty-ms