I try to create a plugin for WordPress that require in some point of the code to send some information to my server. The plugin will be installed in several servers, with diferent configurations and capabilities.
What I like to do is to make that script to be able to communicate with my server (just to call a specific URL of my server) in any kind of PHP Configuration and server capabilities.
Here is my code:
ini_set("allow_url_fopen", 1);
$d = array('key1' => 'val1', 'key2' => 'val2');
$data = urlencode(serialize($d));
$f = fopen('http://www.my-site.ext/getdata/' . $data . '/', 'r');
if(!$f)
{
$ch = curl_init();
if($ch != false)
{
curl_setopt($ch, CURLOPT_URL, 'http://www.my-site.ext/getdata/' . $data . '/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$contents = curl_exec ($ch);
curl_close ($ch);
}
else
{
// IS THERE ANY OTHER METHOD TO TEST IN CASE
// THE FOPEN AND THE CURL NOT WORK ?
}
}
else
{
fclose($f);
}
So the question is, Is there any other method can I try in case that fopen and cURL not work on specific host ?