How to specify a backup remote webservice?
Posted: Sat Apr 09, 2011 9:52 am
How can I specify a backup remote webservice?
Existing code snippet:
Required code, something along the lines of:
...but if I specifiy a bad URI for myPrimaryServer, myAlternativeServer isn't used. I'm fairly new to PHP, so there could be an error in my code. Can anyone post a solution that would work?
Thanks,
James
Existing code snippet:
- Code: Select all
require_once('./TeraWurflRemoteClient.php');
$data_format = TeraWurflRemoteClient::$FORMAT_JSON;
$timeout = 1;
$method = TeraWurflRemoteClient::$METHOD_CURL; //other option is $METHOD_URL_WRAPPER
$wurflObj = new TeraWurflRemoteClient('http://myPrimaryServer.co.uk/Tera-WURFL/webservice.php',$data_format,$timeout,$method);
$capabilities = array("resolution_width|xhtml_support_level");
$wurflObj->getCapabilitiesFromAgent(TeraWurflRemoteClient::getUserAgent(),$capabilities);
Required code, something along the lines of:
- Code: Select all
require_once('./TeraWurflRemoteClient.php');
$data_format = TeraWurflRemoteClient::$FORMAT_JSON;
$timeout = 1;
$method = TeraWurflRemoteClient::$METHOD_CURL; //other option is $METHOD_URL_WRAPPER
$wurflObj;
try {
$wurflObj = new TeraWurflRemoteClient('http://myPrimaryServer.co.uk/Tera-WURFL/webservice.php',$data_format,$timeout,$method);
}
catch(Exception $e1) {
$wurflObj = new TeraWurflRemoteClient('http://myAlternativeServer.co.uk/Tera-WURFL/webservice.php',$data_format,$timeout,$method);
}
$capabilities = array("resolution_width|xhtml_support_level");
$wurflObj->getCapabilitiesFromAgent(TeraWurflRemoteClient::getUserAgent(),$capabilities);
...but if I specifiy a bad URI for myPrimaryServer, myAlternativeServer isn't used. I'm fairly new to PHP, so there could be an error in my code. Can anyone post a solution that would work?
Thanks,
James