Getting text data from another server

I have a website on another server I need to send a querystring to and it provides me with a number (not in XML, just a plain text #) and I'm having some problems with it. Hoping someone has had experience with this.

$user_email = "[email protected]"
$url = "" . $user_email;
$result = read_file($url);

In such case when viewing the $url in the browser it will be either "0" or "1", however I'm getting an empty return in the result for this query.

The only thing I'm thinking is its because the url is on a different server/site.. but they sent me this as their way to check e-mails, so there has to be some way to do it. The only other thing I was thinking is to take it out of PHP and send an AJAX request, but that seems like more work than its worth. Any suggestions??

Do you have errors enabled (E_ALL)? Are you sure you want to use read_file()? It automatically outputs file contents to the page. Try file_get_contents() or better yet - CURL.

It's actually easier to do in php, as AJAX probably won't allow a different domain for a request. Most browser prevent Cross Site Scripting for security purposes. You need to use php as your proxy, so you could AJAX to your page and get the string, and output it back. Using curl would be:
$curl = curl_init();
curl_set_opt($curl, CURLOPT_URL, "" . $user_email);

ob_start(); //start output buffer

curl_exec($curl); //get data
$string = ob_get_contents(); //save data

ob_end_clean(); //clean up
curl_close($curl); //clean up

Sweet! Curl worked perfectly, thanks for the suggestion Smile

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.