我需要在服务器端发出跨域请求
我有两台不同的服务器。
我使用一台服务器来管理所有数据和系统。
另一个服务器只是为了给用户积分。
我需要在服务器端用 php 调用我的第一个服务器, 到第二个服务器,并从服务器获取响应。
PHP 中的示例:
$response = getDataFromOtherServer("http://otherServer.com");
// manipulate response
I have 2 different servers of mine.
I am using one server for managing all the data, and the system.
The other server is just for giving user points.
I need to to make a call in my first server on server side in php,
to the second server, and to get response from the server.
Example in PHP:
$response = getDataFromOtherServer("http://otherServer.com");
// manipulate response
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
你可以做这样的事情
you could do something like this
您可以通过更改与主机 1 等服务器的连接来切换从 2 个服务器获取数据
执行host1的数据并保存。现在,当您需要来自 host2 的数据时,请连接到该主机并操作您的数据
You can switch between getting data from 2 servers by changing the connection to those servers like for host 1
execute data for host1 and save. Now when you need data from host2 connect to that and manipulate your data
使用 Phil Sturgeon 的 REST API ->
休息服务器:
https://github.com/philsturgeon/codeigniter-restserver
REST 客户端:
https://github.com/philsturgeon/codeigniter-restclient
use REST API from Phil Sturgeon ->
REST SERVER:
https://github.com/philsturgeon/codeigniter-restserver
REST CLIENT:
https://github.com/philsturgeon/codeigniter-restclient
假设您的数据服务器上有一个 Web 服务,您可以使用 CURL 向该服务发出 HTTP 请求。 http://php.net/manual/en/book.curl.php
Assuming that you have a web service on your data server, you can use CURL to make HTTP requests to that service. http://php.net/manual/en/book.curl.php