I want to cache HttpSocket->post
calling in CakePHP 2.
I'm calling the following code:
$content = Cache::remember($key, function () use ($rateUrl, $xml, $uid) {
App::uses('HttpSocket', 'Network/Http');
$HttpSocket = new HttpSocket(array('ssl_verify_peer' => false));
return $HttpSocket->post($rateUrl, $xml->asXML(), array(
'header' => array(
'Content-Type' => 'text/xml',
'RestUid' => $uid,
)
));
});
But I'm getting this error:
The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "HttpSocketResponse" of the object you are trying to operate on was loaded before unserialize() gets called or provide a __autoload() function to load the class definition
Do anybody know the way how to use the HttpSocket
class in an anonymous function or call in CakePHP or otherwise?