No Description

SetTopicAttributeResponse.php 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace AliyunMNS\Responses;
  3. use AliyunMNS\Constants;
  4. use AliyunMNS\Exception\MnsException;
  5. use AliyunMNS\Exception\TopicNotExistException;
  6. use AliyunMNS\Exception\InvalidArgumentException;
  7. use AliyunMNS\Responses\BaseResponse;
  8. use AliyunMNS\Common\XMLParser;
  9. class SetTopicAttributeResponse extends BaseResponse
  10. {
  11. public function __construct()
  12. {
  13. }
  14. public function parseResponse($statusCode, $content)
  15. {
  16. $this->statusCode = $statusCode;
  17. if ($statusCode == 204) {
  18. $this->succeed = TRUE;
  19. } else {
  20. $this->parseErrorResponse($statusCode, $content);
  21. }
  22. }
  23. public function parseErrorResponse($statusCode, $content, MnsException $exception = NULL)
  24. {
  25. $this->succeed = FALSE;
  26. $xmlReader = $this->loadXmlContent($content);
  27. try {
  28. $result = XMLParser::parseNormalError($xmlReader);
  29. if ($result['Code'] == Constants::INVALID_ARGUMENT)
  30. {
  31. throw new InvalidArgumentException($statusCode, $result['Message'], $exception, $result['Code'], $result['RequestId'], $result['HostId']);
  32. }
  33. if ($result['Code'] == Constants::TOPIC_NOT_EXIST)
  34. {
  35. throw new TopicNotExistException($statusCode, $result['Message'], $exception, $result['Code'], $result['RequestId'], $result['HostId']);
  36. }
  37. throw new MnsException($statusCode, $result['Message'], $exception, $result['Code'], $result['RequestId'], $result['HostId']);
  38. }
  39. catch (\Exception $e)
  40. {
  41. if ($exception != NULL)
  42. {
  43. throw $exception;
  44. }
  45. elseif ($e instanceof MnsException)
  46. {
  47. throw $e;
  48. }
  49. else
  50. {
  51. throw new MnsException($statusCode, $e->getMessage());
  52. }
  53. }
  54. catch (\Throwable $t)
  55. {
  56. throw new MnsException($statusCode, $t->getMessage());
  57. }
  58. }
  59. }
  60. ?>