No Description

UnsubscribeResponse.php 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace AliyunMNS\Responses;
  3. use AliyunMNS\Exception\MnsException;
  4. use AliyunMNS\Responses\BaseResponse;
  5. use AliyunMNS\Common\XMLParser;
  6. class UnsubscribeResponse extends BaseResponse
  7. {
  8. public function __construct()
  9. {
  10. }
  11. public function parseResponse($statusCode, $content)
  12. {
  13. $this->statusCode = $statusCode;
  14. if ($statusCode == 204)
  15. {
  16. $this->succeed = TRUE;
  17. }
  18. else
  19. {
  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. throw new MnsException($statusCode, $result['Message'], $exception, $result['Code'], $result['RequestId'], $result['HostId']);
  30. } catch (\Exception $e) {
  31. if ($exception != NULL) {
  32. throw $exception;
  33. } elseif($e instanceof MnsException) {
  34. throw $e;
  35. } else {
  36. throw new MnsException($statusCode, $e->getMessage());
  37. }
  38. } catch (\Throwable $t) {
  39. throw new MnsException($statusCode, $t->getMessage());
  40. }
  41. }
  42. }
  43. ?>