有很多方法可以做到这一点,一种方法是SOAP客户端/服务器解决方案..:
你基本上有2个php文件,server1上的一个文件可以说是client.php,而在另一台服务器上有一个名为server.php的文件,它将接收从服务器1上的client.php发送的所有数据......这里是一个简单的来源,您需要将脚本中的 URL 更改为您的服务器/客户端 URL,以便它工作..:
客户端.php
<?php
//This is the SOAP Client which will call a method on Server 2 with passing some data:
//uri is the location where client.php is located, and "location" is the exact location to the client, including the name "client.php"
$client=new SoapClient(NULL,array("uri"=>"http://localhost/test","location"=>"http://localhost/test/test.php"));
$message=$client->hello("Hello World");
echo($message);
?>
服务器.php
<?php
//This is the SOAP Server
class server2{
public function hello($data){
return "I received following data: " . $data;
}
}
//the URI here is the location where the server.php is located.
$settings = array("uri"=>"http://localhost/test/");
$s=new SoapServer(null,$settings);
$s->setClass("server2");
$s->handle();
?>