Nessuna descrizione

SubscribeRequest.php 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace AliyunMNS\Requests;
  3. use AliyunMNS\Constants;
  4. use AliyunMNS\Requests\BaseRequest;
  5. use AliyunMNS\Model\SubscriptionAttributes;
  6. class SubscribeRequest extends BaseRequest
  7. {
  8. private $attributes;
  9. public function __construct(SubscriptionAttributes $attributes)
  10. {
  11. parent::__construct('put', 'topics/' . $attributes->getTopicName() . '/subscriptions/' . $attributes->getSubscriptionName());
  12. $this->attributes = $attributes;
  13. }
  14. public function getSubscriptionAttributes()
  15. {
  16. return $this->attributes;
  17. }
  18. public function generateBody()
  19. {
  20. $xmlWriter = new \XMLWriter;
  21. $xmlWriter->openMemory();
  22. $xmlWriter->startDocument("1.0", "UTF-8");
  23. $xmlWriter->startElementNS(NULL, "Subscription", Constants::MNS_XML_NAMESPACE);
  24. $this->attributes->writeXML($xmlWriter);
  25. $xmlWriter->endElement();
  26. $xmlWriter->endDocument();
  27. return $xmlWriter->outputMemory();
  28. }
  29. public function generateQueryString()
  30. {
  31. return NULL;
  32. }
  33. }
  34. ?>