I have been trying to get facebook page feed from json data with jquery. so far I have been able to get page details with my method but when I try to get page's feed it gives me an error and in the console it says "syntax error: invalid label". this is my code.....

I also have created a jsfiddle with the whole code. check it out if required -> http://jsfiddle.net/yZn7N/.
I can see all the json data if I go to the specified link and they do get fetched and I'm not sure what's causing the invalid label error. Any kind of help fixing it or explanation of why this is happening will be gratefully appreciated.

I have seen in some blogs that access token is required but isn't there any way to do it without the access token? I mean I can pull page's info without the access token so why not the feed? probably it's a silly question lol. thanks for your reply.
–
Foysal AhmedAug 13 '12 at 0:08

I have already put json as my requested format, you'll see it if you look closely to the given url. The issue here is I'm trying to get json data and as I've told you I can see all the json data if I go to the given link (I'll be glad if you have a look for yourself) as well ass rss and atom feed but when I try to pull it from my localhost with a jquery get json call or ajax call it fails and gives me the error saying "invalid label error" in my console. I hope I made my problem a but more clear in here.
–
Foysal AhmedAug 13 '12 at 10:34

3

OK, I've checked the request/response with JQuery and I have bad news. You need to have the &callback=? part in your request because you are making a cross domain request. This involves JSONP and there's no way of getting rid of it. The error that you are receiving is because the answer sent by facebook is not in JSONP format. You need to wrap the Facebook call by implementing a proxy in your website so that you call your aspx/php/jsp page, then the page call Facebook, then the page gives you the answer in the proper format (pass-through is proxy-page is in the same domain, JSONP if not)
–
Adrian SalazarAug 13 '12 at 20:54

Yeah that makes more sense. I was thinking of using secondary php file to retrieve the json data but it was bugging me to know what the issue could be. I also read some articles saying the "invalid label" error cause due to data error in datatype but I was thinking that if the page details call works why won't the page feed work the same way. :( Nevertheless Thanks for your help. I really appreciate your work and interest to help me. :)
–
Foysal AhmedAug 13 '12 at 22:53

I have tried it without the callback thing and it just sends an ajax request which strangely returns an empty response. and as far as I'm concerned facebook isn't blocking js fiddle cause I have seen a lots of fiddles containing facebook api demonstration. In fact I have created one for you jsfiddle.net/33e4M As you can see it works fine with the page details json data but as soon as I implement the same thing with page feed it fails and sends me and empty response
–
Foysal AhmedAug 13 '12 at 10:48

When I run your code as written, there is an Unexpected token error due to the callback. Removing &callback=? changes the error to "XMLHttpRequest cannot load ... Origin fiddle.jshell.net is not allowed" Your other fiddle is using a different endpoint, which can have different access rules. This gives me the idea that Facebook is crippling this endpoint.
–
cpilkoAug 13 '12 at 12:42