问题描述
我在js中创建一个将在多个网站上实现的窗口小部件,
Facebook要求我将其提供给我的域名,以便他们知道我已通过验证。
问题是,该小部件将从许多网站使用,我不打算将所有这些域名列出到Facebook。
如何使我的应用程序从这些不同的网站使用js只要? (对于窗口小部件)
I am creating a widget in js that will be implemented across many websites,
Facebook requires me to give them "my domain" so they will know that I am verified.
The problem is that the widget will be used from many websites, and I am not going to manuly list all of those domains to Facebook.
How can I enable my app to work from those different websites using js only? (for the widget)
提前感谢。
推荐答案
i使用ajax类似的东西。 i ajax到php页面,并使用php sdk的所有请求。
i use ajax for something similar. i ajax to a php page, and use the php sdk for all the requests. cross domain just fine.
示例:应要求在Facebook上更新最新相册,并在Facebook上显示与相册相链接的封面照片。
EXAMPLE: should request most recent albums updated on facebook and display cover photo linked to the album on facebook.
<div id="pagealbums"></div>
<script>
function showAlbums(){
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttpA=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttpA=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttpA.onreadystatechange=function()
{
if (xmlhttpA.readyState==4 && xmlhttpA.status==200)
{
document.getElementById("pagealbums").innerHTML=xmlhttpA.responseText;
}
};
xmlhttpA.open("GET","http://anotherfeed.com/feed.albums.php?pageid=facebook&type=list",true);
xmlhttpA.send();
}
showAlbums();
</script>
这篇关于Facebook使用来自不同域的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!