No Description

AlipayMobilePublicMultiMediaExecute.php 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. private $code = 200 ;
  10. private $msg = '';
  11. private $body = '';
  12. private $params = '';
  13. private $fileSuffix = array(
  14. "image/jpeg" => 'jpg', //+
  15. "text/plain" => 'text'
  16. );
  17. /*
  18. * @$header : 头部
  19. * */
  20. function __construct( $header, $body, $httpCode ){
  21. $this -> code = $httpCode;
  22. $this -> msg = '';
  23. $this -> params = $header ;
  24. $this -> body = $body;
  25. }
  26. /**
  27. *
  28. * @return text | bin
  29. */
  30. public function getCode(){
  31. return $this -> code ;
  32. }
  33. /**
  34. *
  35. * @return text | bin
  36. */
  37. public function getMsg(){
  38. return $this -> msg ;
  39. }
  40. /**
  41. *
  42. * @return text | bin
  43. */
  44. public function getType(){
  45. $subject = $this -> params ;
  46. $pattern = '/Content\-Type:([^;]+)/';
  47. preg_match($pattern, $subject, $matches);
  48. if( $matches ){
  49. $type = $matches[1];
  50. }else{
  51. $type = 'application/download';
  52. }
  53. return str_replace( ' ', '', $type );
  54. }
  55. /**
  56. *
  57. * @return text | bin
  58. */
  59. public function getContentLength(){
  60. $subject = $this -> params ;
  61. $pattern = '/Content-Length:\s*([^\n]+)/';
  62. preg_match($pattern, $subject, $matches);
  63. return (int)( isset($matches[1] ) ? $matches[1] : '' );
  64. }
  65. public function getFileSuffix( $fileType ){
  66. $type = isset( $this -> fileSuffix[ $fileType ] ) ? $this -> fileSuffix[ $fileType ] : 'text/plain' ;
  67. if( !$type ){
  68. $type = 'json';
  69. }
  70. return $type;
  71. }
  72. /**
  73. *
  74. * @return text | bin
  75. */
  76. public function getBody(){
  77. //header('Content-type: image/jpeg');
  78. return $this -> body ;
  79. }
  80. /**
  81. * 获取参数
  82. * @return text | bin
  83. */
  84. public function getParams(){
  85. return $this -> params ;
  86. }
  87. }