Jump to content

pulling variables from other servers


Q695

Recommended Posts

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

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?

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...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.