Andreas Grech
Andreas Grech

Reputation: 107940

Making Facebook's Graph API with tokens work in Internet Explorer

I've encountered several issues while trying to get Facebook's Graph API work in IE.

The first problem was that I was getting a No Transport when making a call to https://graph.facebook.com. The issue here is XDomainRequest and was eventually solved by using this workaround: https://github.com/jaubourg/ajaxHooks/blob/master/src/ajax/xdr.js (I'm using jQuery and XDomainRequest is not supported)

Now the problem that I have is that I'm getting "Access is Denied" while making calls to https://graphs.facebook.com. After some reading, I found out from here that:

7) Requests must be targeted to the same scheme as the hosting page

And of course, I was making calls from http (my domain) to https (graphs.facebook), and that goes against the aforementioned point #7.

So what I first tried was to make a call to http://graphs.facebook.com instead, and that works...but only when not using an access_token in your request; and I need to include my token in all the requests.

So, apart from buying a certificate and putting my site on https (which I won't do), what can I do to make successful ajax calls to a domain which uses a different scheme in IE?

Upvotes: 1

Views: 1929

Answers (1)

DMCS
DMCS

Reputation: 31870

Your AJAX call must be a JSONP type, not a JSON type. The P in JSONP is the way to get around the issue with IE. See an example here for calling with JSONP to facebook. How to query the Facebook Graph API with JSONP

Upvotes: 2

Related Questions