コード例 #1
0
ファイル: AbstractGoGrid.php プロジェクト: navassouza/zf2
 /**
  *
  * @param string $method
  * @param array $options
  * @return array|boolean
  */
 protected function _call($method, $options = null)
 {
     if (!empty($options) && !is_array($options)) {
         throw new Exception\InvalidArgumentException("The options must be an array");
     }
     $client = $this->getHttpClient();
     $paramGet = array('format' => self::FORMAT_API, 'api_key' => $this->_apiKey, 'sig' => $this->_computeSignature(), 'v' => $this->_apiVersion);
     if (!empty($options)) {
         $get = '';
         foreach ($options as $key => $value) {
             if (is_array($value)) {
                 foreach ($value as $val) {
                     $get .= $key . '=' . urlencode($val) . '&';
                 }
             } else {
                 $paramGet[$key] = $value;
             }
         }
     }
     $client->setParameterGet($paramGet);
     if (!empty($get)) {
         $client->setUri(self::URL_API . $method . '?' . $get);
     } else {
         $client->setUri(self::URL_API . $method);
     }
     $this->_lastResponse = $client->send();
     return json_decode($this->_lastResponse->getBody(), true);
 }
コード例 #2
0
ファイル: Response.php プロジェクト: niallmccrudden/zf2
    /**
     * Gets the document object for this response
     *
     * @return DOMDocument the DOM Document for this response.
     */
    public function getDocument()
    {
        try {
            $body = $this->_httpResponse->getBody();
        } catch (Http\Exception $e) {
            $body = false;
        }

        if ($this->_document === null) {
            if ($body !== false) {
                // turn off libxml error handling
                $errors = libxml_use_internal_errors();

                $this->_document = new \DOMDocument();
                if (!$this->_document->loadXML($body)) {
                    $this->_document = false;
                }
                
                // reset libxml error handling
                libxml_clear_errors();
                libxml_use_internal_errors($errors);
            } else {
                $this->_document = false;
            }
        }

        return $this->_document;
    }
コード例 #3
0
ファイル: Storage.php プロジェクト: alab1001101/zf2
 /** 
  * Parse result from Zend_Http_Response
  *
  * @param Zend_Http_Response $response Response from HTTP call
  * @return object
  * @throws Zend_Service_WindowsAzure_Exception
  */
 protected function _parseResponse(Zend\Http\Response $response = null)
 {
     if ($response === null) {
         throw new Zend_Service_WindowsAzure_Exception('Response should not be null.');
     }
     $xml = @simplexml_load_string($response->getBody());
     if ($xml !== false) {
         // Fetch all namespaces
         $namespaces = array_merge($xml->getNamespaces(true), $xml->getDocNamespaces(true));
         // Register all namespace prefixes
         foreach ($namespaces as $prefix => $ns) {
             if ($prefix != '') {
                 $xml->registerXPathNamespace($prefix, $ns);
             }
         }
     }
     return $xml;
 }