Hi everybody!
I have 2 files on 2 different servers:
file1.php - resides on site 1 - I pass a parameter, and the script echo-ed answer which depends on (is function of) passed parameter - everithink is OK when I access file by browser like
http://site1.com/file1.php?parameterValue
file2.php - resides on site 2 - file2 has to send a parameter to file1.php AND get echo-ed output from it as variable.
I tried to do it by 3 diferent ways but no ones worked.
way 1. -------
function get_data($url)
{
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$f="http://site1.com/file1.php?parameterValue";
$returned_content = get_data($f);
echo "=== $returned_content ===";exit;
way 2. -------
$f="http://site1.com/file1.php?parameterValue";
$returned_content='';
$file = fopen ($f, "r");
if (!$file) {
echo "<p>Unable to open remote file.\n";
exit;
}
while (!feof ($file)) $returned_content.= fgets ($file, 1024);
fclose($file);
echo "=-= $returned_content =-=";exit;
way 3. -------
$f="http://site1.com/file1.php?parameterValue";
$returned_content=implode('',file($f));
echo "=-= $returned_content =-=";exit;
BUT $returned_content is empty string ...
Can anybody help me? Thanks in advance!
Hristo