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