0

So I am encountering a strange situation with a php curl request. It works perfectly when the script is called from the same local network as the server which is running it but when somebody calls it from outside is not working anymore. This is my code:

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, ROOT_DIR."directory/someScript.php");
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 1);
    $output = curl_exec($ch);
    curl_close($ch);

When I run someScript.php manually even from outside the LAN it works just fine. The issue occurs only when it I try to run it by calling it with curl via another php script. Anybody have any idea? The curl library is enabled. And both scripts are on the same server. I am using port forwarding on port 80 to make the server visible in the Internet.

Andrei Puf
  • 81
  • 9
  • 1
    Try turning on error reporting and use E_ALL. – CuriousMind Oct 21 '14 at 05:51
  • You can Trace the CURL request - http://stackoverflow.com/questions/3252851/how-to-display-request-headers-with-command-line-curl – user269867 Oct 21 '14 at 06:28
  • I am using Windows with Xampp and I tried to get the error from curl with **curl_error** function from php and no error is returned. But still the php script that should be called is not run. – Andrei Puf Oct 22 '14 at 05:32

1 Answers1

0

I decided to post the solution in case somebody else has the same problem. In the end I found the cause for this. The problem was that I was calling the script using the external IP instead of the internal one. Further more because of this XAMPP redirected the call to its default page and because I didn't use the output I did not noticed that.

Andrei Puf
  • 81
  • 9