K
K
K. A.2016-04-08 19:56:19
PHP
K. A., 2016-04-08 19:56:19

Why does cURL work locally, but not on hosting?

Good afternoon!
Straight to the point:
There is a script:

if($_GET['method'] == 'register')
{
  if(isset($_GET['amount']) & isset($_GET['guest_name']) & isset($_GET['phone']) & isset($_GET['room']) & isset($_GET['arrival']))
  {
    if(!empty($_GET['amount']) & !empty($_GET['guest_name']) & !empty($_GET['phone']) & !empty($_GET['room']) & !empty($_GET['arrival']))
    {
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, $main_server.$register.'?userName='.$merchant['login'].'&password='.$merchant['password'].'&amount='.$_GET['amount'].'&orderNumber='.$orderNumber.'&returnUrl='.$returnUrl);
      curl_setopt($ch, CURLOPT_HEADER, false);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
      curl_setopt($ch, CURLOPT_USERAGENT, 'PHP Gateway ');
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
      curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
      $data = curl_exec($ch);
      curl_close($ch);
      $data_arr = json_decode($data, true);

      if(isset($data_arr['errorCode']) & !empty($data_arr['errorCode']))
      {
        die('Произошла ошибка: ' . $data_arr['errorCode'] . ' : ' . $data_arr['errorMessage']);
      }
      else
      {	
        header("Location: " . $data_arr['formUrl']);
        exit();
      }
    }
    else
    {
      die("Один или несколько параметров пусты");
    }

  }
  else
  {
    die("Один или несколько параметров не заданы");
  }
}

Upon receiving all incoming parameters, the script sends a GET request to the server, which in turn returns a json object containing either a link to the generated page, or an error code with decryption. When an error is returned, they are displayed; if the link is successfully generated, the script immediately redirects the user's browser to the received link.
The problem is that everything works fine on the local server as it should, but as soon as I upload the script to the hosting and access it, there is no redirection. I dug around and noticed that after executing the cURL request, I don’t get anything, and accordingly I don’t see any redirect link or error either. I checked if cURL is enabled on the hosting - everything is as it should, I tried to redirect to a direct link - the same order,error_reporting(E_ALL);
doesn't show anything either. What else could be the problem? Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2016-04-08
@dimonchik2013

if curl is definitely displayed in phpinfo as installed - add debugging and see

c.setopt(c.VERBOSE, 1)
c.setopt(pycurl.DEBUGFUNCTION, Test)

the Test function is written, not built-in, something like writing to a file, log, screen, etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question