Search code examples
facebookcross-domainfacebook-appsfacebook-app-requests

Facebook Using code from different domains


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)

Thanks in advance.


Solution

  • 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.

    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>