Q695 Posted December 1, 2008 Share Posted December 1, 2008 I'm working on a project that requires people to post some data on other servers to just add particular features. How would I most easily pull the variables onto my server with every click that is done? Link to comment https://forums.phpfreaks.com/topic/134935-pulling-variables-from-other-servers/ Share on other sites More sharing options...
cooldude832 Posted December 1, 2008 Share Posted December 1, 2008 XML is the preferred porting method to bridge languages/servers. If its MySQL and you have rights to read said database that is another way to do it. If you own the other server there are tons of ways to do it If not you need to figure out the data and its format Link to comment https://forums.phpfreaks.com/topic/134935-pulling-variables-from-other-servers/#findComment-702712 Share on other sites More sharing options...
rhodesa Posted December 1, 2008 Share Posted December 1, 2008 you can have the remote server post data to your server via cURL. just pick a common format like XML or JSON. or you can have the users send you the data every page visit via JavaScript (kind of like Google Analytics). Basically you load a PHP file as a JavaScript file. What kind of 'variables' are you looking to send? Link to comment https://forums.phpfreaks.com/topic/134935-pulling-variables-from-other-servers/#findComment-702756 Share on other sites More sharing options...
Q695 Posted December 1, 2008 Author Share Posted December 1, 2008 Can I see the curl syntax, because I've never done it before? I'm building an application that could be used on other sites by simply doing a simple inclusion statement. Link to comment https://forums.phpfreaks.com/topic/134935-pulling-variables-from-other-servers/#findComment-703203 Share on other sites More sharing options...
rhodesa Posted December 1, 2008 Share Posted December 1, 2008 on the remote servers, that are posting data, it would look like this: <?php $data = array( 'key1' => 'value1', 'key2' => 'value2', ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"http://www.yourserver.com/page.php"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); $output = curl_exec($ch); curl_close($ch); echo $output; ?> and then on your server, in page.php, you can access the data via $_POST if you elaborate more on what you are trying to do i can have a better recommendation on what to do... Link to comment https://forums.phpfreaks.com/topic/134935-pulling-variables-from-other-servers/#findComment-703381 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.