我正在尝试为Google Chrome创建一个扩展程序,以便我阅读Facebook页面的对话(消息)。现在,我在使用chrome扩展程序登录facebook时遇到了麻烦。我收到错误“无法加载网址:此网址的域未包含在应用的域中。要加载此网址,请将应用的所有域和子域添加到您的应用领域字段中应用设置。“我对如何进行没有一个明确的想法。有人可以指出什么是错的,或者可以建议一个更好的替代方案,使用谷歌浏览器扩展中的Graph API阅读Facebook页面的对话。或者可以作为Firefox附加组件使用? 这是我正在使用的代码
的manifest.json
{
"name": "Facebook Connect For Chrome Extension",
"version": "1.0",
"description": "This plugin is showing how Facebook Connect/Graph API works on Chrome Extension.",
"content_security_policy": "script-src 'self' https://connect.facebook.net; object-src 'self'",
"background":
{"page":"background.html"
},
"browser_action": {
"default_popup": "popup.html",
"default_icon":"icon.png"
},
"manifest_version":2,
"permissions": [
"tabs",
"http://*.facebook.com/*"
]
}
popup.html
<html>
<head>
<title>Facebook Connect For Chrome Extension</title>
<script type="text/javascript" src="popup.js"></script>
</head>
<body>
<h1>Facebook Connect For Chrome Extension</h1>
<div id='status'></div>
</body>
</html>
popup.js
window.addEventListener("load", function(){
window.fbAsyncInit = function() {
FB.init({
appId : '197374294047884',
xfbml : true,
version : 'v2.8'
});
FB.AppEvents.logPageView();
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
document.getElementById('status').innerHTML = 'Connceted'
// the user is logged in and has authenticated your
// app, and response.authResponse supplies
// the user's ID, a valid access token, a signed
// request, and the time the access token
// and signed request each expire
var uid = response.authResponse.userID;
var accessToken = response.authResponse.accessToken;
} else if (response.status === 'not_authorized') {
// the user is logged in to Facebook,
document.getElementById('status').innerHTML = 'not autorized'
// but has not authenticated your app
} else {
// the user isn't logged in to Facebook.
document.getElementById('status').innerHTML = 'not connected'
}
});
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "https://connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
});