![]() |
|
|
|
|
1
3rd July 16:32
External User
Posts: 1
|
Yes; some kind of Remote Procedure Call protocol (eg SOAP) is designed for
this. But the lightweight way would be something like: function get_token_validity ($token) { $token = 'token=' . rawurlencode ($token); // armour message for sending $host = 'www.webserverA.com'; if (($sp = fsockopen ($host, 80)) == FALSE) { return (NULL); } fputs ($sp, "POST /path/to/script.php HTTP/1.0\r\n"); fputs ($sp, "Host: $host\r\n"); fputs ($sp, "Content-type: application/x-www-form-urlencoded\r\n"); fputs ($sp, "Content-length: " . strlen ($token) . "\r\n\r\n"); fputs ($sp, "$token\r\n"); $result = NULL; while (!feof ($sp)) { $a = fgets ($sp); if (is_numeric ($a)) { if ($a == FALSE) { $result = FALSE; } else { $result = TRUE; } } } fclose ($sp); return ($result); } Untested, but it should be pretty close. Returns TRUE on a valid result, FALSE on invalid and NULL on error. The paired script on www.webserverA.com should just echo(1) or echo(0) for a good or bad result. /Ah/. I have to ask... why? I have no idea whether the above code will run on PHP 3. |
|
|
|