how facebook does cross domain ajax call?

后端 未结 3 1137
说谎
说谎 2021-01-14 00:45

I am looking forward to create a javascript API that contains most of the functions that facebook Javascript API provides.

FB.api
FB.init
FB.logout
FB.getLog         


        
相关标签:
3条回答
  • 2021-01-14 01:28

    They are using JSONP. It's widely used and is supported by javascript frameworks like JQuery.

    0 讨论(0)
  • 2021-01-14 01:31

    Take a look at https://github.com/facebook/facebook-js-sdk/blob/deprecated/src/core/xd.js

    They use a combination of rpc workarounds (with a relay file), Flash Local Connection and postMessage, whichever is supported by the browser.

    0 讨论(0)
  • 2021-01-14 01:32

    You can also take a look at Cross Site XmlHttpRequest(CORS). From your question, it seems that you can control your server that will respond to the requests. In that case, you can tune the headers to receive requests and respond to cross domain requests.

    Then, your embedded script will be able to talk to your server from any web page if you configure the request header in the requests that you make from your embedded script.

    I like this method as it is extremely easy to implement. Watch out for browser support though!

    0 讨论(0)
提交回复
热议问题