I’m working on building an extension for Google Chrome that requires a background script to connect to Facebook and make calls to the Graph API and FQL. Unfortunately, I’ve hit a bit of a roadblock in terms of how to implement this. Chrome uses a built-in CSP to block any inline scripts from running and I haven’t had any luck with using JQuery to load the JavaScript SDK for Facebook.
Does anybody have an idea of how to implement this? I can’t move forward until I can even load the SDK for Facebook.
You need to write the JavaScript in your extension to access the public Facebook API. You will also need to get an OAuth2 token for the user to access their public data. Here are some projects that may help you:
https://github.com/jjNford/html5-storage
https://github.com/jjNford/chrome-extension-socket
https://github.com/jjNford/oauth2-chrome-extension
The first is an HTML5 localStorage wrapper to help you with storing some data in the browser storage (do not store personal data). The second uses the Chrome APIs to create a port between a background page and popup to allow for 2 way communication so you can offload your API requests. The third is a solution to get OAuth2 inside a Chrome Extension – you will need to tweak it to Facebooks specs.
Hope this helps.