且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Blogger上的服务器端代理

更新时间:2023-11-27 22:00:16

您可以使用称为的东西. JSONP ,但前提是您所调用的网站提供的API将以正确的格式返回响应.

You can use what has become known as JSONP, but only if the site you're calling provides an API that will return a response in the correct format.

否则,是的,通常可以在任何Web容器的顶部实现服务器端代理支持.这就要求您具有直接访问服务器的权限(即,如果您的网站托管在blogger.com上,则该服务器将无法工作),具体细节将取决于您的实现语言和网络容器.但是,高级流程非常简单:

Otherwise, yes, it is generally possible to implement server-side proxy support on top of any web container. This requires that you have direct access to the server (i.e. it won't work if your site is hosted on blogger.com), and the exact specifics will vary depending upon your implementation language and web container. The high-level flow is very simple, however:

  1. 客户端使用标准XMLHttpRequest通过诸如/proxyRequest?url=http://www.crossdomain.com/someNeatThing之类的请求回调服务器.
  2. 服务器触发对"http://www.crossdomain.com/someNeatThing"的请求,获取响应,并通过proxyRequest调用将其通过管道传回客户端.
  1. The client calls back to the server with a request like /proxyRequest?url=http://www.crossdomain.com/someNeatThing, using a standard XMLHttpRequest.
  2. The server fires off its own request to 'http://www.crossdomain.com/someNeatThing', grabs the response, and pipes it back to the client as the result of the proxyRequest call.