示例#1
0
 /**
  * Constructs a new Zend_Service_Technorati instance
  * and setup character encoding.
  *
  * @param  string $apiKey  Your Technorati API key
  */
 public function __construct($apiKey)
 {
     Zend_EncodingProxy::setOutputEncoding('UTF-8');
     Zend_EncodingProxy::setInputEncoding('UTF-8');
     Zend_EncodingProxy::setInternalEncoding('UTF-8');
     $this->_apiKey = $apiKey;
 }
 /**
  * Sets up character encoding, instantiates the HTTP client, and assigns the web service version.
  */
 public function __construct()
 {
     $this->set('version', '1.0');
     Zend_EncodingProxy::setOutputEncoding('UTF-8');
     Zend_EncodingProxy::setInputEncoding('UTF-8');
     Zend_EncodingProxy::setInternalEncoding('UTF-8');
 }
示例#3
0
 /**
  * Perform an XML-RPC request and return a response.
  *
  * @param Zend_XmlRpc_Request $request
  * @param null|Zend_XmlRpc_Response $response
  * @return void
  * @throws Zend_XmlRpc_Client_HttpException
  */
 public function doRequest($request, $response = null)
 {
     $this->_lastRequest = $request;
     Zend_EncodingProxy::setOutputEncoding('UTF-8');
     Zend_EncodingProxy::setInputEncoding('UTF-8');
     Zend_EncodingProxy::setInternalEncoding('UTF-8');
     $http = $this->getHttpClient();
     if ($http->getUri() === null) {
         $http->setUri($this->_serverAddress);
     }
     $http->setHeaders(array('Content-Type: text/xml; charset=utf-8', 'Accept: text/xml'));
     if ($http->getHeader('user-agent') === null) {
         $http->setHeaders(array('User-Agent: Zend_XmlRpc_Client'));
     }
     $xml = $this->_lastRequest->__toString();
     $http->setRawData($xml);
     $httpResponse = $http->request(Zend_Http_Client::POST);
     if (!$httpResponse->isSuccessful()) {
         /**
          * Exception thrown when an HTTP error occurs
          * @see Zend_XmlRpc_Client_HttpException
          */
         // require_once 'Zend/XmlRpc/Client/HttpException.php';
         throw new Zend_XmlRpc_Client_HttpException($httpResponse->getMessage(), $httpResponse->getStatus());
     }
     if ($response === null) {
         $response = new Zend_XmlRpc_Response();
     }
     $this->_lastResponse = $response;
     $this->_lastResponse->loadXml(trim($httpResponse->getBody()));
 }