The other day I noticed that some of our applications that used Facebook FBJS AJAX calls were not working properly. One or two clients made mention of it so I decided to research further.
AJAX calls that once worked on Facebook where now returning a "not so descriptive" error message:
There was an uncaught Ajax error. Please attach on onerror handler to properly handle failures.
After some research I discovered that suddenly the Facebook AJAX call was no longer accepting URLs to CANVAS pages. In the past the thinking was simple, make an AJAX call to a canvas page and the page receiving the call has access to the Facebook API (user object, datastore, messaging, notification, i.e.)
The "fix" is simple, where ever you make a AJAX call to a canvas page URL that looks like this:
ajax.post("http://apps.facebook.com/MYAPP/ajax.php")
You need to change it to point to a page that hangs off your call back URL, so something like this:
ajax.post("http://my.call-back-url.com/appdirectory/ajax.php")
The real problem is you many need to rewrite the page you were making the call to since the previously used technique of accessing the Facebook API via an AJAX call no longer seems to be working! Here are some thoughts and recommendations:
- If you are associated user data in your database using a user's Facebook ID (which you should), you will need to send that with your AJAX call (appending as part of a query string)
- User preferences that need to be changed using AJAX should be moved from the Facebook database to your database (ouch!)
- Example all your ajax calls (hopefully you have them organized seperated) to make sure none of them require that the Facebook API be included. "Silent calls" that are used to trigger notifications or updates may have stopped working without your knowledge. (versus more visible UI calls that may simply 'break the app')
Metablocks Clients: By now, all your Facebook applications should have been updated to address this change to the API. If you have any questions or concerns, please contact your account manager.