web/lib/Zend/Service/Audioscrobbler.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 Audioscrobbler
    18  * @subpackage Audioscrobbler
    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: Audioscrobbler.php 24593 2012-01-05 20:35:02Z matthew $
    21  * @version    $Id$
    22  */
    22  */
    23 
    23 
    24 
    24 
    25 /**
    25 /**
    26  * @see Zend_Http_Client
    26  * @see Zend_Http_Client
    27  */
    27  */
    28 require_once 'Zend/Http/Client.php';
    28 require_once 'Zend/Http/Client.php';
    29 
    29 
       
    30 /** @see Zend_Xml_Security */
       
    31 require_once 'Zend/Xml/Security.php';
    30 
    32 
    31 /**
    33 /**
    32  * @category   Zend
    34  * @category   Zend
    33  * @package    Zend_Service
    35  * @package    Zend_Service
    34  * @subpackage Audioscrobbler
    36  * @subpackage Audioscrobbler
    35  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    37  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
    36  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    38  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    37  */
    39  */
    38 class Zend_Service_Audioscrobbler
    40 class Zend_Service_Audioscrobbler
    39 {
    41 {
    40     /**
    42     /**
    67      */
    69      */
    68     public function __construct()
    70     public function __construct()
    69     {
    71     {
    70         $this->set('version', '1.0');
    72         $this->set('version', '1.0');
    71 
    73 
    72         iconv_set_encoding('output_encoding', 'UTF-8');
    74         if (PHP_VERSION_ID < 50600) {
    73         iconv_set_encoding('input_encoding', 'UTF-8');
    75             iconv_set_encoding('output_encoding', 'UTF-8');
    74         iconv_set_encoding('internal_encoding', 'UTF-8');
    76             iconv_set_encoding('input_encoding', 'UTF-8');
       
    77             iconv_set_encoding('internal_encoding', 'UTF-8');
       
    78         } else {
       
    79             ini_set('output_encoding', 'UTF-8');
       
    80             ini_set('input_encoding', 'UTF-8');
       
    81             ini_set('default_charset', 'UTF-8');
       
    82         }
    75     }
    83     }
    76 
    84 
    77     /**
    85     /**
    78      * Set Http Client
    86      * Set Http Client
    79      *
    87      *
   180             throw new Zend_Http_Client_Exception('The web service ' . $this->_client->getUri() . ' returned the following status code: ' . $response->getStatus());
   188             throw new Zend_Http_Client_Exception('The web service ' . $this->_client->getUri() . ' returned the following status code: ' . $response->getStatus());
   181         }
   189         }
   182 
   190 
   183         set_error_handler(array($this, '_errorHandler'));
   191         set_error_handler(array($this, '_errorHandler'));
   184 
   192 
   185         if (!$simpleXmlElementResponse = simplexml_load_string($responseBody)) {
   193         if (!$simpleXmlElementResponse = Zend_Xml_Security::scan($responseBody)) {
   186             restore_error_handler();
   194             restore_error_handler();
   187             /**
   195             /**
   188              * @see Zend_Service_Exception
   196              * @see Zend_Service_Exception
   189              */
   197              */
   190             require_once 'Zend/Service/Exception.php';
   198             require_once 'Zend/Service/Exception.php';
   638      * @param  string  $errfile
   646      * @param  string  $errfile
   639      * @param  integer $errline
   647      * @param  integer $errline
   640      * @param  array   $errcontext
   648      * @param  array   $errcontext
   641      * @return void
   649      * @return void
   642      */
   650      */
   643     protected function _errorHandler($errno, $errstr, $errfile, $errline, array $errcontext)
   651     public function _errorHandler($errno, $errstr, $errfile, $errline, array $errcontext)
   644     {
   652     {
   645         $this->_error = array(
   653         $this->_error = array(
   646             'errno'      => $errno,
   654             'errno'      => $errno,
   647             'errstr'     => $errstr,
   655             'errstr'     => $errstr,
   648             'errfile'    => $errfile,
   656             'errfile'    => $errfile,