I am trying to use Zend_Cache with Service_Flickr but im getting some
weird output.
Here is my code:
require_once('Zend/Loader.php');
Zend_Loader::loadClass('Zend_Cache');
Zend_Loader::loadClass('Zend_Service_Flickr');
/* Setup cache options */
$frontendOptions = array(
'caching' => true,
'lifetime' => 600, // cache lifetime of 10 minutes
'automatic_serialization' => true
);
$backendOptions = array(
'cache_db_complete_path' => '/tmp/cache.sqlite'
);
/* Init both vars */
$cache = Zend_Cache::factory('Core', 'Sqlite', $frontendOptions,
$backendOptions);
$flickr = new Zend_Service_Flickr('');
if(!$results = $cache->load('flickrcache'))
{
$results = $flickr->groupPoolGetPhotos('');
$cache->save($results, 'flickrcache');
}
echo '<pre>';
print_r($results);
echo '</pre>';
$num = 0;
foreach ($results as $result)
{
echo '<a href="'.$result->Large->clickUri.'"><img
src="'.$result->Square->uri.'" border="0" /></a> ';
$num++;
if($num == 4) echo '<br />';
if($num == 8) break;
}
The first time the page loads the $results is this:
Zend_Service_Flickr_ResultSet Object
(
[totalResultsAvailable] => 122
[totalResultsReturned] => 10
[firstResultPosition] => 1
[_results:protected] => DOMNodeList Object
(
)
[_flickr:private] => Zend_Service_Flickr Object
(
[apiKey] =>
[_restClient:protected] => Zend_Rest_Client Object
(
[_data:protected] => Array
(
)
[_uri:protected] => Zend_Uri_Http Object
(
[_username:protected] =>
[_password:protected] =>
[_host:protected] => www.flickr.com
[_port:protected] => 80
[_path:protected] => /services/rest/
[_query:protected] =>
[_fragment:protected] =>
[_regex:protected] => Array
(
[alphanum] => [^\W_]
[escaped] => (?:%[\da-fA-F]{2})
[mark] => [-_.!~*'()\[\]]
[reserved] => [;\/?:@&=+$,]
[unreserved] => (?:[^\W_]|[-_.!~*'()\[\]])
[segment] =>
(?:(?:(?:[^\W_]|[-_.!~*'()\[\]])|(?:%[\da-fA-F]{2})|[:@&=+$,;])*)
[path] =>
(?:\/(?:(?:(?:[^\W_]|[-_.!~*'()\[\]])|(?:%[\da-fA-F]{2})|[:@&=+$,;])*)?)+
[uric] =>
(?:[;\/?:@&=+$,]|(?:[^\W_]|[-_.!~*'()\[\]])|(?:%[\da-fA-F]{2}))
)
[_scheme:protected] => http
)
)
)
[_currentIndex:private] => 0
)
Then after the cache it loads as so:
__PHP_Incomplete_Class Object
(
[__PHP_Incomplete_Class_Name] => Zend_Service_Flickr_ResultSet
[totalResultsAvailable] => 122
[totalResultsReturned] => 10
[firstResultPosition] => 1
[_results:protected] => DOMNodeList Object
(
)
[_flickr:private] => Zend_Service_Flickr Object
(
[apiKey] =>
[_restClient:protected] => __PHP_Incomplete_Class Object
(
[__PHP_Incomplete_Class_Name] => Zend_Rest_Client
[_data:protected] => Array
(
)
[_uri:protected] => __PHP_Incomplete_Class Object
(
[__PHP_Incomplete_Class_Name] => Zend_Uri_Http
[_username:protected] =>
[_password:protected] =>
[_host:protected] => www.flickr.com
[_port:protected] => 80
[_path:protected] => /services/rest/
[_query:protected] =>
[_fragment:protected] =>
[_regex:protected] => Array
(
[alphanum] => [^\W_]
[escaped] => (?:%[\da-fA-F]{2})
[mark] => [-_.!~*'()\[\]]
[reserved] => [;\/?:@&=+$,]
[unreserved] => (?:[^\W_]|[-_.!~*'()\[\]])
[segment] =>
(?:(?:(?:[^\W_]|[-_.!~*'()\[\]])|(?:%[\da-fA-F]{2})|[:@&=+$,;])*)
[path] =>
(?:\/(?:(?:(?:[^\W_]|[-_.!~*'()\[\]])|(?:%[\da-fA-F]{2})|[:@&=+$,;])*)?)+
[uric] =>
(?:[;\/?:@&=+$,]|(?:[^\W_]|[-_.!~*'()\[\]])|(?:%[\da-fA-F]{2}))
)
[_scheme:protected] => http
)
)
)
[_currentIndex:private] => 0
)
Is there something I am missing? I cant figure out why its not working
or what I need to do to get the results the same.
Thanks in advance,
Ian
没有评论:
发表评论