web/lib/Zend/Service/Flickr.php
changeset 1230 68c69c656a2c
parent 807 877f952ae2bd
equal deleted inserted replaced
1229:5a6b6e770365 1230:68c69c656a2c
    14  * to license@zend.com so we can send you a copy immediately.
    14  * to license@zend.com so we can send you a copy immediately.
    15  *
    15  *
    16  * @category   Zend
    16  * @category   Zend
    17  * @package    Zend_Service
    17  * @package    Zend_Service
    18  * @subpackage Flickr
    18  * @subpackage Flickr
    19  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    19  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
    20  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    20  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    21  * @version    $Id: Flickr.php 24593 2012-01-05 20:35:02Z matthew $
    21  * @version    $Id$
    22  */
    22  */
    23 
    23 
       
    24 /** @see Zend_Xml_Security */
       
    25 require_once 'Zend/Xml/Security.php';
    24 
    26 
    25 /**
    27 /**
    26  * @category   Zend
    28  * @category   Zend
    27  * @package    Zend_Service
    29  * @package    Zend_Service
    28  * @subpackage Flickr
    30  * @subpackage Flickr
    29  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    31  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
    30  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    32  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    31  */
    33  */
    32 class Zend_Service_Flickr
    34 class Zend_Service_Flickr
    33 {
    35 {
    34     /**
    36     /**
    35      * Base URI for the REST client
    37      * Base URI for the REST client
    36      */
    38      */
    37     const URI_BASE = 'http://www.flickr.com';
    39     const URI_BASE = 'https://www.flickr.com';
    38 
    40 
    39     /**
    41     /**
    40      * Your Flickr API key
    42      * Your Flickr API key
    41      *
    43      *
    42      * @var string
    44      * @var string
   112             throw new Zend_Service_Exception('An error occurred sending request. Status code: '
   114             throw new Zend_Service_Exception('An error occurred sending request. Status code: '
   113                                            . $response->getStatus());
   115                                            . $response->getStatus());
   114         }
   116         }
   115 
   117 
   116         $dom = new DOMDocument();
   118         $dom = new DOMDocument();
   117         $dom->loadXML($response->getBody());
   119         $dom = Zend_Xml_Security::scan($response->getBody(), $dom);
   118 
       
   119         self::_checkErrors($dom);
   120         self::_checkErrors($dom);
   120 
   121 
   121         /**
   122         /**
   122          * @see Zend_Service_Flickr_ResultSet
   123          * @see Zend_Service_Flickr_ResultSet
   123          */
   124          */
   176             throw new Zend_Service_Exception('An error occurred sending request. Status code: '
   177             throw new Zend_Service_Exception('An error occurred sending request. Status code: '
   177                                            . $response->getStatus());
   178                                            . $response->getStatus());
   178         }
   179         }
   179 
   180 
   180         $dom = new DOMDocument();
   181         $dom = new DOMDocument();
   181         $dom->loadXML($response->getBody());
   182         $dom = Zend_Xml_Security::scan($response->getBody(), $dom);
   182 
       
   183         self::_checkErrors($dom);
   183         self::_checkErrors($dom);
   184 
   184 
   185         /**
   185         /**
   186          * @see Zend_Service_Flickr_ResultSet
   186          * @see Zend_Service_Flickr_ResultSet
   187          */
   187          */
   231             throw new Zend_Service_Exception('An error occurred sending request. Status code: '
   231             throw new Zend_Service_Exception('An error occurred sending request. Status code: '
   232                                            . $response->getStatus());
   232                                            . $response->getStatus());
   233         }
   233         }
   234 
   234 
   235         $dom = new DOMDocument();
   235         $dom = new DOMDocument();
   236         $dom->loadXML($response->getBody());
   236         $dom = Zend_Xml_Security::scan($response->getBody(), $dom);
   237 
       
   238         self::_checkErrors($dom);
   237         self::_checkErrors($dom);
   239 
   238 
   240         /**
   239         /**
   241         * @see Zend_Service_Flickr_ResultSet
   240         * @see Zend_Service_Flickr_ResultSet
   242         */
   241         */
   281             throw new Zend_Service_Exception('An error occurred sending request. Status code: '
   280             throw new Zend_Service_Exception('An error occurred sending request. Status code: '
   282                                            . $response->getStatus());
   281                                            . $response->getStatus());
   283         }
   282         }
   284 
   283 
   285         $dom = new DOMDocument();
   284         $dom = new DOMDocument();
   286         $dom->loadXML($response->getBody());
   285         $dom = Zend_Xml_Security::scan($response->getBody(), $dom);
   287         self::_checkErrors($dom);
   286         self::_checkErrors($dom);
   288         $xpath = new DOMXPath($dom);
   287         $xpath = new DOMXPath($dom);
   289         return (string) $xpath->query('//user')->item(0)->getAttribute('id');
   288         return (string) $xpath->query('//user')->item(0)->getAttribute('id');
   290     }
   289     }
   291 
   290 
   325             throw new Zend_Service_Exception('An error occurred sending request. Status code: '
   324             throw new Zend_Service_Exception('An error occurred sending request. Status code: '
   326                                            . $response->getStatus());
   325                                            . $response->getStatus());
   327         }
   326         }
   328 
   327 
   329         $dom = new DOMDocument();
   328         $dom = new DOMDocument();
   330         $dom->loadXML($response->getBody());
   329         $dom = Zend_Xml_Security::scan($response->getBody(), $dom);
   331         self::_checkErrors($dom);
   330         self::_checkErrors($dom);
   332         $xpath = new DOMXPath($dom);
   331         $xpath = new DOMXPath($dom);
   333         return (string) $xpath->query('//user')->item(0)->getAttribute('id');
   332         return (string) $xpath->query('//user')->item(0)->getAttribute('id');
   334     }
   333     }
   335 
   334 
   358         $restClient = $this->getRestClient();
   357         $restClient = $this->getRestClient();
   359         $restClient->getHttpClient()->resetParameters();
   358         $restClient->getHttpClient()->resetParameters();
   360         $response = $restClient->restGet('/services/rest/', $options);
   359         $response = $restClient->restGet('/services/rest/', $options);
   361 
   360 
   362         $dom = new DOMDocument();
   361         $dom = new DOMDocument();
   363         $dom->loadXML($response->getBody());
   362         $dom = Zend_Xml_Security::scan($response->getBody(), $dom);
   364         $xpath = new DOMXPath($dom);
   363         $xpath = new DOMXPath($dom);
   365         self::_checkErrors($dom);
   364         self::_checkErrors($dom);
   366         $retval = array();
   365         $retval = array();
   367         /**
   366         /**
   368          * @see Zend_Service_Flickr_Image
   367          * @see Zend_Service_Flickr_Image