Wstar Posted May 26, 2010 Share Posted May 26, 2010 I was wondering how this is possible with php. I've looked everywhere for an answer. There is a company that makes memberships and they have a script that creates them. Its nothing but a long URL. When the URL is sent, their server replies with a message telling me its done (or if there is a problem). Is there a way php can send the request and get the response? The URL i sent is something like this: http://www.company.com/create.php?action=add_member&user=VALUE&pass=VALUE There are a lot more variables in the URL, but its close. Just wondering if there was something like this out there.... $server_reply = function(URL)?? Link to comment https://forums.phpfreaks.com/topic/202969-running-a-scripted-from-a-different-server/ Share on other sites More sharing options...
ignace Posted May 26, 2010 Share Posted May 26, 2010 You can do the same thing: server1 $username = isset($_GET['username']) ? $_GET['username'] : 'no username defined'; echo 'Hello, ', $username; server2 print file_get_contents('http://www.server1.com/script.php?username=me');//Hello, me Link to comment https://forums.phpfreaks.com/topic/202969-running-a-scripted-from-a-different-server/#findComment-1063603 Share on other sites More sharing options...
kenrbnsn Posted May 26, 2010 Share Posted May 26, 2010 You can use one of file, file_get_contents, or curl functions. Ken Link to comment https://forums.phpfreaks.com/topic/202969-running-a-scripted-from-a-different-server/#findComment-1063607 Share on other sites More sharing options...
Wstar Posted May 26, 2010 Author Share Posted May 26, 2010 Thanks so much. The replies pointed me just where I needed. I came up with the following, and it works great. $fd = fopen ($url, "r"); $buffer = ''; while(! feof($fd)){ $buffer .= fgets ($fd, 1024); } fclose($fd); $url stores the url and $buffer is the response that I get. Thanks again! Link to comment https://forums.phpfreaks.com/topic/202969-running-a-scripted-from-a-different-server/#findComment-1063611 Share on other sites More sharing options...
kenrbnsn Posted May 26, 2010 Share Posted May 26, 2010 The file or file_get_contents functions do the same thing in much less code. Ken Link to comment https://forums.phpfreaks.com/topic/202969-running-a-scripted-from-a-different-server/#findComment-1063613 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.