I have a PHP CRON script that use to execute the external url using the code below every 5 minutes: echo file("https://...");

This line of code is not working after i upgrade my server from VPS to Dedicated Server. Is that anything to do to the WHM tweak, firewall, or security?

  • To further clarify my issue: I have also tried "file_get_contents" but no luck. And when i try to refresh my page in the browser url. The url is executed.
    – Lukas Tan
    Sep 24 '20 at 13:37

First, you have to enable the common PHP setting if the server setup by your self in VPS/Dedicated server. You can also get the content from URL using the CURL method. It is proper method compare to file get contents because it provide more settings. Notes: CURL setting must be enable on your server.

// Initiate curl session in a variable (resource)
$curl_handle = curl_init();

$url = "http://dummy.restapiexample.com/api/v1/employees";

// Set the curl URL option
curl_setopt($curl_handle, CURLOPT_URL, $url);

// This option will return data as a string instead of direct output
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true);

// Execute curl & store data in a variable
$curl_data = curl_exec($curl_handle);


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.