Jaxel
Well-known member
I have the following function in my mod:
Simple right? It connects to a JSON file, and parses it based on submitted data.
However, you can occasionally get errors such as:
Code:
public function retrieveData($data)
{
$feed = "http://www.stopforumspam.com/api?".
($data['username'] ? 'username='.$data['username'].'&' : '').
($data['email'] ? 'email='.$data['email'].'&' : '').
($data['ip'] ? 'ip='.$data['ip'].'&' : '').
"f=json";
$client = new Zend_Http_Client($feed);
$feed = $client->request()->getBody();
$json = json_decode($feed, true);
return $json;
}
However, you can occasionally get errors such as:
I would rather the system handled these failures silently, and the function returned "false". Is this possible?Zend_Http_Client_Adapter_Exception: Unable to Connect to tcp://www.stopforumspam.com:80. Error #110: Connection timed out - library/Zend/Http/Client/Adapter/Socket.php:235
Generated By: Unknown Account, Yesterday at 9:26 PM
#0 /library/Zend/Http/Client.php(973): Zend_Http_Client_Adapter_Socket->connect('www.stopforumsp...', 80, false)
#1 /library/EWRutiles/Model/ForumSpam.php(17): Zend_Http_Client->request()
#2 /library/EWRutiles/ControllerPublic/Register.php(16): EWRutiles_Model_ForumSpam->checkDatabase(Array)
#3 /library/XenForo/FrontController.php(310): EWRutiles_ControllerPublic_Register->actionRegister()
#4 /library/XenForo/FrontController.php(132): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
#5 /index.php(15): XenForo_FrontController->run()
#6 {main}