2

I'm using the following code to remotely execute a script:

$url = 'https://x.x.com/update_something.cfm?something_id=' . $id;
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
            $response = curl_exec($ch);
            curl_close($ch);

The script, however, it's not being executed (when I visit the url above from the browser, I can see the updated results, when doing it from the php script above nothing happens. PHP is not giving me any errors though, it just finishes the execution. What am I missing?

David Faber
  • 12,277
  • 2
  • 29
  • 40
luqita
  • 4,008
  • 13
  • 60
  • 93
  • 1
    Try turning the `CURLOPT_VERBOSE` option on to get some debugging info, and also check the return value of `curl_error()` to be sure. If nothing obvious is wrong with the request, try modifying the request headers to resemble your browser's request more closely, sometimes scripts whine about things like `User-Agent` and `Referer` headers. – Another Code Mar 12 '12 at 16:32
  • Do a `var_dump($response)` after the exec call. if it comes out boolean false, then something didn't work right with the curl call. You can get the error text with `echo curl_error($ch)` – Marc B Mar 12 '12 at 16:35
  • Thanks, I ran it and got 'SSL connection timeout', not sure how to solve this, I tried CURLOPT_TIMEOUT to a high number but it's not working :( – luqita Mar 12 '12 at 17:14

1 Answers1

0

Adding curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); made it work! :)

luqita
  • 4,008
  • 13
  • 60
  • 93
  • Please note that [disabling VERIFYPEER or VERIFYHOST makes the connection vulnerable to MITM attacks](http://stackoverflow.com/a/13742121/372643). – Bruno Nov 21 '14 at 11:24