当前位置: 首页>>代码示例>>PHP>>正文


PHP Response::xml方法代码示例

本文整理汇总了PHP中GuzzleHttp\Message\Response::xml方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::xml方法的具体用法?PHP Response::xml怎么用?PHP Response::xml使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GuzzleHttp\Message\Response的用法示例。


在下文中一共展示了Response::xml方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: contentToProperty

 /**
  * Converts the <content> section to an array and stores as an object property.
  */
 private function contentToProperty()
 {
     $xml_response = json_decode(json_encode((array) $this->http_response_object->xml()), 1);
     if (isset($xml_response['content'])) {
         $this->xmws_content_array = $xml_response['content'];
         $this->xmws_content_string = $xml_response['content'];
     }
 }
开发者ID:KevinFairbanks,项目名称:senitor,代码行数:11,代码来源:XmwsResponse.php

示例2: createMessage

 /**
  * @param Response $response
  *
  * @return string
  */
 protected static function createMessage(Response $response)
 {
     if ($response->getStatusCode() != 400) {
         return '[' . $response->getStatusCode() . '] A HTTP error has occurred: ' . $response->getBody(true);
     }
     $message = 'Some errors occurred:';
     foreach ($response->xml()->error as $error) {
         $message .= PHP_EOL . '[' . (string) $error->code . '] ' . (string) $error->message;
     }
     return $message;
 }
开发者ID:leonardorifeli,项目名称:pagseguro,代码行数:16,代码来源:PagSeguroException.php

示例3: parseResponse

 /**
  * Parse the returned response.
  *
  * @param  \GuzzleHttp\Message\Response  $response
  * @return array
  *
  * @throws \RuntimeException
  */
 protected function parseResponse(Response $response)
 {
     $contentType = explode(';', $response->getHeader('content-type'))[0];
     switch ($contentType) {
         case 'text/javascript':
         case 'application/json':
             return $response->json();
         case 'application/xml':
             return $response->xml();
     }
     throw new \RuntimeException("Unsupported returned content-type [{$contentType}]");
 }
开发者ID:pcextreme,项目名称:cloudstack-client,代码行数:20,代码来源:CloudstackConnector.php

示例4: testPreventsComplexExternalEntities

 public function testPreventsComplexExternalEntities()
 {
     $xml = '<?xml version="1.0"?><!DOCTYPE scan[<!ENTITY test SYSTEM "php://filter/read=convert.base64-encode/resource=ResponseTest.php">]><scan>&test;</scan>';
     $response = new Response(200, array(), Stream::factory($xml));
     $oldCwd = getcwd();
     chdir(__DIR__);
     try {
         $xml = $response->xml();
         chdir($oldCwd);
         $this->markTestIncomplete('Did not throw the expected exception! XML resolved as: ' . $xml->asXML());
     } catch (\Exception $e) {
         chdir($oldCwd);
     }
 }
开发者ID:ChenOhayon,项目名称:sitepoint_codes,代码行数:14,代码来源:ResponseTest.php

示例5: __construct

 /**
  * Construct a Ping response from an HTTP response.
  *
  * @param Response $response
  */
 public function __construct(Response $response)
 {
     $this->response = $response;
     $this->status = $response->getStatusCode();
     $this->error = null;
     $this->xml = null;
     $this->body = $response->getBody();
     try {
         $this->xml = $response->xml();
     } catch (Exception $ex) {
         $this->error = $ex->getMessage();
     } catch (XmlParseException $ex) {
         $this->error = $ex->getMessage();
     }
 }
开发者ID:ubermichael,项目名称:pkppln-php,代码行数:20,代码来源:PingResult.php

示例6: parseBody

 /**
  * {@inheritdoc}
  */
 public function parseBody(Response $response, $format = '')
 {
     $output = NULL;
     if (empty($format)) {
         $format = isset($this->defaults['form']) ? $this->defaults['form'] : NULL;
     }
     if ($format == $this::FORMAT_JSON || $format == $this::FORMAT_CJSON) {
         $output = $response->json();
     }
     if ($format == $this::FORMAT_ATOM || $format == $this::FORMAT_RSS) {
         $output = $this->xmlToArray($response->xml());
     }
     if ($output['isException']) {
         throw new MpxException(sprintf('Exception returned: %s', print_r($output, TRUE)), $output['responseCode']);
     }
     if (isset($output)) {
         return $output;
     }
     throw new MpxException('Custom formats are not supported.');
 }
开发者ID:robcolburn,项目名称:mpx-php,代码行数:23,代码来源:Client.php

示例7: decodeRequest

 /**
  * Decodes the API response from XML to a JSON array.
  *
  * @param Response $response
  * @return array
  */
 protected function decodeRequest(Response $response)
 {
     // check if XML received
     $xml = $response->xml();
     return json_decode(json_encode($xml), true);
 }
开发者ID:sadhakbj,项目名称:resourcecontracts.org,代码行数:12,代码来源:MechanicalTurk.php

示例8: detectType

 private function detectType(\GuzzleHttp\Message\Response $response)
 {
     switch ($response->getHeader('content-type')) {
         case 'application/json':
             return $response->json();
             break;
         case 'application/xml':
         case 'text/xml':
             return json_decode(json_encode($response->xml()), true);
             break;
         default:
             return $response->getBody();
     }
 }
开发者ID:skizu,项目名称:simpleapi,代码行数:14,代码来源:RegisterAPI.php


注:本文中的GuzzleHttp\Message\Response::xml方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。