我需要在服务器端进行跨域请求

时间:2012-02-08 14:00:03

标签: php cross-domain

我有两台不同的服务器。

我使用一台服务器来管理所有数据和系统。

另一台服务器仅用于提供用户点数。

我需要在php的服务器端的第一台服务器上打电话, 到第二台服务器,并从服务器获得响应。

PHP中的示例:

$response = getDataFromOtherServer("http://otherServer.com");
// manipulate response

4 个答案:

答案 0 :(得分:2)

你可以做这样的事情

$response = fopen("http://otherServer.com?var1=some&var2=thing","r");

答案 1 :(得分:0)

您可以通过更改与主机1等服务器的连接来切换从2台服务器获取数据

  

的mysql_connect( '主机1', '用户名', '密码')

执行host1的数据并保存。现在,当您需要来自host2的数据连接到该数据并操纵您的数据时

答案 2 :(得分:0)

使用Phil Sturgeon的REST API - >

REST SERVER: https://github.com/philsturgeon/codeigniter-restserver

REST客户端 https://github.com/philsturgeon/codeigniter-restclient

答案 3 :(得分:0)

假设您的数据服务器上有Web服务,您可以使用CURL向该服务发出HTTP请求。 http://php.net/manual/en/book.curl.php