No Description

SetAccountAttributesResponse.php 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace AliyunMNS\Responses;
  3. use AliyunMNS\Constants;
  4. use AliyunMNS\Exception\MnsException;
  5. use AliyunMNS\Responses\BaseResponse;
  6. use AliyunMNS\Common\XMLParser;
  7. class SetAccountAttributesResponse extends BaseResponse
  8. {
  9. public function __construct()
  10. {
  11. }
  12. public function parseResponse($statusCode, $content)
  13. {
  14. $this->statusCode = $statusCode;
  15. if ($statusCode == 204) {
  16. $this->succeed = TRUE;
  17. } else {
  18. $this->parseErrorResponse($statusCode, $content);
  19. }
  20. }
  21. public function parseErrorResponse($statusCode, $content, MnsException $exception = NULL)
  22. {
  23. $this->succeed = FALSE;
  24. $xmlReader = $this->loadXmlContent($content);
  25. try {
  26. $result = XMLParser::parseNormalError($xmlReader);
  27. throw new MnsException($statusCode, $result['Message'], $exception, $result['Code'], $result['RequestId'], $result['HostId']);
  28. } catch (\Exception $e) {
  29. if ($exception != NULL) {
  30. throw $exception;
  31. } elseif($e instanceof MnsException) {
  32. throw $e;
  33. } else {
  34. throw new MnsException($statusCode, $e->getMessage());
  35. }
  36. } catch (\Throwable $t) {
  37. throw new MnsException($statusCode, $t->getMessage());
  38. }
  39. }
  40. }
  41. ?>