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


PHP Response::xml方法代码示例

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


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

示例1: xml

 /**
  * {@inheritdoc}
  */
 public function xml()
 {
     try {
         $result = $this->response->xml();
     } catch (\Exception $exception) {
         throw GuzzleRestException::createFromException($exception);
     }
     return $result;
 }
开发者ID:ramunasd,项目名称:platform,代码行数:12,代码来源:GuzzleRestResponse.php

示例2: getContent

 private function getContent(Response $response)
 {
     if ($response->isContentType('xml')) {
         return $response->xml();
     } elseif ($response->isContentType('audio')) {
         return $response->getBody()->getStream();
     } else {
         return $response->getBody();
     }
 }
开发者ID:gquemener,项目名称:7digital-client,代码行数:10,代码来源:Service.php

示例3: 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:amaurymedeiros,项目名称:pagseguro,代码行数:16,代码来源:PagSeguroException.php

示例4: decodeResponse

 public function decodeResponse(Response $response)
 {
     $rootElement = dom_import_simplexml($response->xml());
     $doc = $rootElement->ownerDocument;
     $xpath = new DOMXPath($doc);
     $faultElement = $xpath->query("/methodResponse/fault");
     if ($faultElement->length > 0) {
         $errorCodeList = $xpath->query("/methodResponse/fault[1]/value[1]/struct[1]/member[name='faultCode']/value/int");
         $errorMessageList = $xpath->query("/methodResponse/fault[1]/value[1]/struct[1]/member[name='faultString']/value/string");
         $errorCode = $errorCodeList->length > 0 ? (int) $errorCodeList->item(0)->nodeValue : null;
         $errorMessage = $errorMessageList->length > 0 ? (string) $errorMessageList->item(0)->nodeValue : "";
         throw new RpcErrorException($errorMessage, $errorCode);
     }
     if (($params = $xpath->evaluate("/methodResponse/params/param")) instanceof DomNodeList && $params->length > 0) {
         $results = array();
         foreach ($params as $paramElement) {
             $results[] = $this->parameterDeserializer->getValueFromDomElement($paramElement);
         }
         return $results;
     }
     throw new RpcNoResultException();
 }
开发者ID:mdjward,项目名称:php-rpc-client,代码行数:22,代码来源:XmlRpcEncoder.php

示例5: testThrowsExceptionWhenFailsToParseXmlResponse

 /**
  * @covers Guzzle\Http\Message\Response::xml
  * @expectedException \Guzzle\Common\Exception\RuntimeException
  * @expectedExceptionMessage Unable to parse response body into XML: String could not be parsed as XML
  */
 public function testThrowsExceptionWhenFailsToParseXmlResponse()
 {
     $response = new Response(200, array(), '<abc');
     $response->xml();
 }
开发者ID:KANU82,项目名称:guzzle,代码行数:10,代码来源:ResponseTest.php

示例6: 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(), $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:launchdarkly,项目名称:guzzle3,代码行数:14,代码来源:ResponseTest.php

示例7: getContent

 /**
  * @param Response $response
  * @return \SimpleXMLElement
  */
 public static function getContent(Response $response)
 {
     return $response->xml();
 }
开发者ID:ferodss,项目名称:salesforce-api,代码行数:8,代码来源:ResponseMediator.php

示例8: __construct

 public function __construct(RequestInterface $request, HttpResponse $response)
 {
     parent::__construct($request, $response->xml());
     $this->isSuccessful = $response->isSuccessful();
 }
开发者ID:bamarni,项目名称:omnipay-ideal,代码行数:5,代码来源:FetchIssuersResponse.php

示例9: testPreventsComplexExternalEntities

 /**
  * @expectedException \Guzzle\Common\Exception\RuntimeException
  */
 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(), $xml);
     $oldCwd = getcwd();
     chdir(__DIR__);
     try {
         $response->xml();
         chdir($oldCwd);
     } catch (\Exception $e) {
         chdir($oldCwd);
         throw $e;
     }
 }
开发者ID:mickdane,项目名称:zidisha,代码行数:17,代码来源:ResponseTest.php


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