AlipayMobilePublicMultiMediaExecute.php
1.8 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
/**
 * 多媒体文件客户端
 * @author yuanwai.wang
 * @version $Id: AlipayMobilePublicMultiMediaExecute.php, v 0.1 Aug 15, 2014 10:19:01 AM yuanwai.wang Exp $
 */
//namespace alipay\api ;
class AlipayMobilePublicMultiMediaExecute{
	private $code = 200 ;
	private $msg = '';
	private $body = '';
	private $params = '';
	private $fileSuffix = array(
		"image/jpeg" 		=> 'jpg', //+
		"text/plain"		=> 'text'
	);
	/*
	 * @$header : 头部
	 * */
	function __construct( $header, $body, $httpCode ){
		$this -> code = $httpCode;
		$this -> msg = '';
		$this -> params = $header ;
		$this -> body = $body;
	}
	/**
	 *
	 * @return text | bin
	 */
	public function getCode(){
		return $this -> code ;
	}
	/**
	 *
	 * @return text | bin
	 */
	public function getMsg(){
		return $this -> msg ;
	}
	/**
	 *
	 * @return text | bin
	 */
	public function getType(){
		$subject = $this -> params ;
		$pattern = '/Content\-Type:([^;]+)/';
		preg_match($pattern, $subject, $matches);
		if( $matches ){
			$type = $matches[1];
		}else{
			$type = 'application/download';
		}
		return str_replace( ' ', '', $type );
	}
	/**
	 *
	 * @return text | bin
	 */
	public function getContentLength(){
		$subject = $this -> params ;
		$pattern = '/Content-Length:\s*([^\n]+)/';
		preg_match($pattern, $subject, $matches);
		return (int)( isset($matches[1] ) ? $matches[1]  : '' );
	}
	public function getFileSuffix( $fileType ){
		$type = isset( $this -> fileSuffix[ $fileType ] ) ? $this -> fileSuffix[ $fileType ] : 'text/plain' ;
		if( !$type ){
			$type = 'json';
		}
		return $type;
	}
	/**
	 *
	 * @return text | bin
	 */
	public function getBody(){
		//header('Content-type: image/jpeg');
		return $this -> body ;
	}
	/**
	 * 获取参数
	 * @return text | bin
	 */
	public function getParams(){
		return $this -> params ;
	}
}