Skip to content

Instantly share code, notes, and snippets.

@danielcharrua
Last active March 10, 2022 13:05
Show Gist options
  • Select an option

  • Save danielcharrua/25f04d9231e29c216c6ee8f14595fef0 to your computer and use it in GitHub Desktop.

Select an option

Save danielcharrua/25f04d9231e29c216c6ee8f14595fef0 to your computer and use it in GitHub Desktop.
Test WordPress sitehealth loopback
<?php
//
// A very simple PHP example that sends a HTTP POST to a remote site
// Put this file in your project root directory and execute in browser
// If you see an error, probably the Loopback on Site Health will be also failing, solve this and test again.
//
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://meninos.org/wp-cron.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "postvar1=value1&postvar2=value2&postvar3=value3");
// In real life you should use something like:
// curl_setopt($ch, CURLOPT_POSTFIELDS,
// http_build_query(array('postvar1' => 'value1')));
// Receive server response ...
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec($ch);
// Check for errors
if (curl_errno($ch)) {
$error_msg = curl_error($ch);
}
curl_close ($ch);
// Further processing ...
if ($server_output == "OK") {
echo 'OK';
} else {
echo 'error';
var_dump($error_msg);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment