Yes.
A good way I can think of would be to send a request to the 2nd server via the url. In the GET (or POST) parameters, specify which method you want to call, and (for security) some hash that changes over time. The hash inside is there to ensure that the third party cannot execute the function arbitrarily on the 2nd server.
To send a request, you can use cURL:
function get_url($request_url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $request_url); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec($ch); curl_close($ch); return $response; }
Sends a GET request. Then you can use:
$request_url = 'http://second-server-address/listening_page.php?function=somefunction&securityhash=HASH'; $response = get_url($request_url);
On your second server, set up listening_page.php
(with whatever file name you like, of course), which checks for GET requests and checks for the integrity of the request (i.e. hash, valid and valid parameters).
Alex source share