AlipayMobilePublicMultiMediaExecute.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. /**
  3. * 多媒体文件客户端
  4. * @author yuanwai.wang
  5. * @version $Id: AlipayMobilePublicMultiMediaExecute.php, v 0.1 Aug 15, 2014 10:19:01 AM yuanwai.wang Exp $
  6. */
  7. //namespace alipay\api ;
  8. class AlipayMobilePublicMultiMediaExecute
  9. {
  10. private $code = 200;
  11. private $msg = '';
  12. private $body = '';
  13. private $params = '';
  14. private $fileSuffix = array(
  15. "image/jpeg" => 'jpg', //+
  16. "text/plain" => 'text'
  17. );
  18. /*
  19. * @$header : 头部
  20. * */
  21. function __construct($header, $body, $httpCode)
  22. {
  23. $this->code = $httpCode;
  24. $this->msg = '';
  25. $this->params = $header;
  26. $this->body = $body;
  27. }
  28. /**
  29. *
  30. * @return text | bin
  31. */
  32. public function getCode()
  33. {
  34. return $this->code;
  35. }
  36. /**
  37. *
  38. * @return text | bin
  39. */
  40. public function getMsg()
  41. {
  42. return $this->msg;
  43. }
  44. /**
  45. *
  46. * @return text | bin
  47. */
  48. public function getType()
  49. {
  50. $subject = $this->params;
  51. $pattern = '/Content\-Type:([^;]+)/';
  52. preg_match($pattern, $subject, $matches);
  53. if ($matches) {
  54. $type = $matches[1];
  55. } else {
  56. $type = 'application/download';
  57. }
  58. return str_replace(' ', '', $type);
  59. }
  60. /**
  61. *
  62. * @return text | bin
  63. */
  64. public function getContentLength()
  65. {
  66. $subject = $this->params;
  67. $pattern = '/Content-Length:\s*([^\n]+)/';
  68. preg_match($pattern, $subject, $matches);
  69. return (int)(isset($matches[1]) ? $matches[1] : '');
  70. }
  71. public function getFileSuffix($fileType)
  72. {
  73. $type = isset($this->fileSuffix[$fileType]) ? $this->fileSuffix[$fileType] : 'text/plain';
  74. if (!$type) {
  75. $type = 'json';
  76. }
  77. return $type;
  78. }
  79. /**
  80. *
  81. * @return text | bin
  82. */
  83. public function getBody()
  84. {
  85. //header('Content-type: image/jpeg');
  86. return $this->body;
  87. }
  88. /**
  89. * 获取参数
  90. * @return text | bin
  91. */
  92. public function getParams()
  93. {
  94. return $this->params;
  95. }
  96. }