Google Chrome如何使用Facebook API? [英] How is it possible to use Facebook APIs with Google Chrome?

查看:196
本文介绍了Google Chrome如何使用Facebook API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Google Chrome构建扩展程序,该扩展程序需要后台脚本才能连接到Facebook并调用Graph API和FQL。不幸的是,就如何实现这一点而言,我遇到了一些障碍。 Chrome使用内置的CSP来阻止任何内嵌脚本运行,并且我还没有使用JQuery为Facebook加载JavaScript SDK的好运。



有没有人有一个如何实现这个想法?我甚至无法前进,直到我甚至可以为Facebook加载SDK。

解决方案

您需要将JavaScript写入您的扩展访问公共Facebook API。您还需要获取OAuth2令牌以供用户访问其公共数据。以下是一些可以帮助您的项目:

https ://github.com/jjNford/html5-storage



https://github.com/jjNford/chrome-extension-socket



https://github.com/jjNford/oauth2-chrome-extension



第一个是HTML5 localStorage包装器,可以帮助您将一些数据存储在浏览器存储中(不要存储个人数据)。第二个使用Chrome API在背景页面和弹出窗口之间创建端口以允许双向通信,因此您可以卸载API请求。第三个是在Chrome扩展中获得OAuth2的解决方案 - 您需要根据Facebook规格进行调整。



希望这有助于您。


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.

这篇关于Google Chrome如何使用Facebook API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆