Jason
Jason

Reputation: 95

How to deal with URLs with commas in Facebook Graph API

I would like to use Graph API to get some information about URLs.

It works like this:

http://graph.facebook.com/?ids=URL,URL2,URL3

However, when an URL contains comma, things get complicated. For

http://www.example.com/name,something

we get

http://graph.facebook.com/?ids=http%3A%2F%2Fwww.example.com%2Fname%2Csomething

what gives us:

{
   "error": {
      "message": "(#803) Some of the aliases you requested do not exist: something",
      "type": "OAuthException",
      "code": 803
   }
}

What can be done with URLs to avoid such errors?

Upvotes: 4

Views: 1116

Answers (1)

C3roe
C3roe

Reputation: 96383

Just double-URL-encode the comma, so use %252C for it:

http://graph.facebook.com/?ids=http%3A%2F%2Fwww.example.com%2Fname%252Csomething

It might look weird, because then the Graph API identifies this URL by http://www.example.com/name\u00252Csomething - but I just tested it by pointing a like button to a URL containing a comma (un-encoded), liked it – and afterwards it showed 1 share for this URL on the Graph.

Upvotes: 7

Related Questions