本文整理汇总了PHP中GuzzleHttp\Message\ResponseInterface::xml方法的典型用法代码示例。如果您正苦于以下问题:PHP ResponseInterface::xml方法的具体用法?PHP ResponseInterface::xml怎么用?PHP ResponseInterface::xml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GuzzleHttp\Message\ResponseInterface
的用法示例。
在下文中一共展示了ResponseInterface::xml方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __invoke
public function __invoke(ResponseInterface $response)
{
\SellerCenter\SDK\Common\AnnotationRegistry::registerAutoloadNamespace();
if (count($response->xml()->xpath('/ErrorResponse'))) {
$serializer = SerializerBuilder::create()->build();
return $serializer->deserialize($response->xml()->asXML(), 'SellerCenter\\SDK\\Common\\Api\\Response\\Error\\ErrorResponse', 'xml');
}
return;
}
示例2: parse
public function parse(Session $rets, ResponseInterface $response, $parameters)
{
$xml = $response->xml();
$rs = new Results();
$rs->setSession($rets)->setResource($parameters['SearchType'])->setClass($parameters['Class']);
if ($this->getRestrictedIndicator($rets, $xml, $parameters)) {
$rs->setRestrictedIndicator($this->getRestrictedIndicator($rets, $xml, $parameters));
}
$rs->setHeaders($this->getColumnNames($rets, $xml, $parameters));
$rets->debug(count($rs->getHeaders()) . ' column headers/fields given');
$this->parseRecords($rets, $xml, $parameters, $rs);
if ($this->getTotalCount($rets, $xml, $parameters) !== null) {
$rs->setTotalResultsCount($this->getTotalCount($rets, $xml, $parameters));
$rets->debug($rs->getTotalResultsCount() . ' total results found');
}
$rets->debug($rs->getReturnedResultsCount() . ' results given');
if ($this->foundMaxRows($rets, $xml, $parameters)) {
// MAXROWS tag found. the RETS server withheld records.
// if the server supports Offset, more requests can be sent to page through results
// until this tag isn't found anymore.
$rs->setMaxRowsReached();
$rets->debug('Maximum rows returned in response');
}
unset($xml);
return $rs;
}
示例3: parse
public function parse(Session $rets, ResponseInterface $response)
{
$xml = $response->xml();
$base = $xml->METADATA->{'METADATA-SYSTEM'};
$metadata = new \PHRETS\Models\Metadata\System();
$metadata->setSession($rets);
$configuration = $rets->getConfiguration();
if ($configuration->getRetsVersion()->is1_5()) {
if (isset($base->System->SystemID)) {
$metadata->setSystemId((string) $base->System->SystemID);
}
if (isset($base->System->SystemDescription)) {
$metadata->setSystemDescription((string) $base->System->SystemDescription);
}
} else {
if (isset($base->SYSTEM->attributes()->SystemID)) {
$metadata->setSystemId((string) $base->SYSTEM->attributes()->SystemID);
}
if (isset($base->SYSTEM->attributes()->SystemDescription)) {
$metadata->setSystemDescription((string) $base->SYSTEM->attributes()->SystemDescription);
}
if (isset($base->SYSTEM->attributes()->TimeZoneOffset)) {
$metadata->setTimezoneOffset((string) $base->SYSTEM->attributes()->TimeZoneOffset);
}
}
if (isset($base->SYSTEM->Comments)) {
$metadata->setComments((string) $base->SYSTEM->Comments);
}
if (isset($base->attributes()->Version)) {
$metadata->setVersion((string) $xml->METADATA->{'METADATA-SYSTEM'}->attributes()->Version);
}
return $metadata;
}
示例4: __construct
/**
* Sets attributes from response xml.
*
* @param ResponseInterface $response
* @param array $attributes
*/
public function __construct(ResponseInterface $response, array $attributes = null)
{
$this->response = $response;
if (is_null($attributes)) {
$attributes = Xml::elementsToArray($response->xml()->xpath('/RESPONSE/FIELDS/*'));
}
parent::__construct($attributes);
}
示例5: __invoke
public function __invoke(CommandInterface $command, ResponseInterface $response)
{
$output = $this->api->getOperation($command->getName())->getOutput();
$xml = $response->xml();
if ($this->honorResultWrapper && $output['resultWrapper']) {
$xml = $xml->{$output['resultWrapper']};
}
return new Result($this->xmlParser->parse($output, $xml));
}
示例6: isUserInSharedData
public function isUserInSharedData($user)
{
$data = $this->response->xml()->data[0];
foreach ($data as $element) {
if ($element->share_with == $user) {
return True;
}
}
return False;
}
示例7: send
/**
* Run request to Restoration Media
*/
public function send()
{
$request = $this->client->createRequest('GET', $this->getBuiltUrl());
$request->setHeader('User-Agent', 'github.com/caseyw/restorationmedia_php');
$this->response = $this->client->send($request);
/*
* Restoration Media doesn't actually use HTTP Status Codes. I don't know why.
*/
return 'success.' == $this->response->xml() ? true : false;
}
示例8: getResponse
protected function getResponse(GuzzleResponse $response)
{
if (strpos($response->getHeader('Content-Type'), 'json')) {
$returnResponse = new JsonResponse($response->getBody());
} elseif (strpos($response->getHeader('Content-Type'), 'xml')) {
$returnResponse = new XmlResponse($response->xml());
} else {
throw new \Exception('Unknow return type');
}
return $returnResponse;
}
示例9: execute
/**
* Execute the command
*
* @param Command $command
* @return bool
*/
public function execute(Command $command)
{
$cookies = CookieJar::fromArray(['TokenKey' => $this->getToken()], $this->hostname);
$client = $this->getClient();
// Get the request method
$method = $command->getMethod();
// get the url
$url = $command->getUrl($this->endpoint);
// create the request object with the cookie
$this->lastRequest = $client->createRequest($method, $url, $command->getPayload(['cookies' => $cookies]));
$this->lastResponse = $client->send($this->lastRequest);
$xml = $this->lastResponse->xml();
return isset($xml->Success) && $xml->Success;
}
示例10: getArrayOfShareesResponded
public function getArrayOfShareesResponded(ResponseInterface $response, $shareeType)
{
$elements = $response->xml()->data;
$elements = json_decode(json_encode($elements), 1);
if (strpos($shareeType, 'exact ') === 0) {
$elements = $elements['exact'];
$shareeType = substr($shareeType, 6);
}
$sharees = [];
foreach ($elements[$shareeType] as $element) {
$sharees[] = [$element['label'], $element['value']['shareType'], $element['value']['shareWith']];
}
return $sharees;
}
示例11: parse
public function parse(Session $rets, ResponseInterface $response)
{
$xml = $response->xml();
$collection = new Collection();
if ($xml->METADATA) {
foreach ($xml->METADATA->{'METADATA-OBJECT'}->Object as $key => $value) {
$metadata = new \PHRETS\Models\Metadata\Object();
$metadata->setSession($rets);
$obj = $this->loadFromXml($metadata, $value, $xml->METADATA->{'METADATA-OBJECT'});
$collection->put($obj->getObjectType(), $obj);
}
}
return $collection;
}
示例12: parse
public function parse(Session $rets, ResponseInterface $response, $keyed_by)
{
$xml = $response->xml();
$collection = new Collection();
if ($xml->METADATA) {
foreach ($xml->METADATA->{'METADATA-TABLE'}->Field as $key => $value) {
$metadata = new \PHRETS\Models\Metadata\Table();
$metadata->setSession($rets);
$this->loadFromXml($metadata, $value, $xml->METADATA->{'METADATA-TABLE'});
$method = 'get' . $keyed_by;
$collection->put((string) $metadata->{$method}(), $metadata);
}
}
return $collection;
}
示例13: parse
public function parse(Session $rets, ResponseInterface $response)
{
$xml = $response->xml();
$collection = new Collection();
if ($xml->METADATA) {
// some servers don't name this correctly for the version of RETS used, so play nice with either way
if (!empty($xml->METADATA->{'METADATA-LOOKUP_TYPE'}->LookupType)) {
$base = $xml->METADATA->{'METADATA-LOOKUP_TYPE'}->LookupType;
} else {
$base = $xml->METADATA->{'METADATA-LOOKUP_TYPE'}->Lookup;
}
foreach ($base as $key => $value) {
$metadata = new \PHRETS\Models\Metadata\LookupType();
$metadata->setSession($rets);
$collection->push($this->loadFromXml($metadata, $value, $xml->METADATA->{'METADATA-LOOKUP_TYPE'}));
}
}
return $collection;
}
示例14: parse
/**
* @param ResponseInterface $response
* @param string $deserialize
*
* @return mixed
*/
protected function parse(ResponseInterface $response, $deserialize)
{
return $this->parser->parse($response->xml(), $deserialize);
}
示例15: parseResponse
/**
* @param string $call
* @param ResponseInterface $rawResponse
*
* @return Response
*/
protected function parseResponse($call, ResponseInterface $rawResponse)
{
$response = new Response();
$responseArray = json_decode(json_encode($rawResponse->xml()), true);
$response->setMethod($call);
if (!array_key_exists('message', $responseArray)) {
$response->setCode(999);
$response->setMessage('Invalid response received.');
} else {
$response->setCode(intval($responseArray['message']['code']));
$response->setMessage($responseArray['message']['text']);
}
if ($response->isSuccessful() && array_key_exists('response', $responseArray)) {
$response->setData($responseArray['response']);
}
return $response;
}