| @@ 26-50 (lines=25) @@ | ||
| 23 | * |
|
| 24 | * @return bool|array 接口返回结果 |
|
| 25 | */ |
|
| 26 | public function upload($file, $type) |
|
| 27 | { |
|
| 28 | if (!$file || !$type) { |
|
| 29 | $this->setError('参数缺失'); |
|
| 30 | ||
| 31 | return false; |
|
| 32 | } |
|
| 33 | ||
| 34 | if (!file_exists($file)) { |
|
| 35 | $this->setError('文件路径不正确'); |
|
| 36 | ||
| 37 | return false; |
|
| 38 | } |
|
| 39 | ||
| 40 | $data = []; |
|
| 41 | $data['media'] = '@' . realpath($file); |
|
| 42 | ||
| 43 | Api::setPostQueryStr('type', $type); |
|
| 44 | ||
| 45 | $node = 'upload'; |
|
| 46 | ||
| 47 | $res = $this->_post($node, $data, false); |
|
| 48 | ||
| 49 | return $res; |
|
| 50 | } |
|
| 51 | ||
| 52 | /** |
|
| 53 | * 上传临时媒体文件. |
|
| @@ 163-185 (lines=23) @@ | ||
| 160 | * |
|
| 161 | * @return string. 获取地址 http://mmbiz.qpic.cn/mmbiz/NdxGKqW8jE9GbAqUEPdSgSvbUbProSmE8NbUFwIYnp0Duibs611ZsCLza6b2dS8Ex3CO5dtv0u1HP9QY32djCxA/0 |
|
| 162 | */ |
|
| 163 | public function uploadimg($file) |
|
| 164 | { |
|
| 165 | if (!$file) { |
|
| 166 | $this->setError('参数缺失'); |
|
| 167 | ||
| 168 | return false; |
|
| 169 | } |
|
| 170 | ||
| 171 | if (!file_exists($file)) { |
|
| 172 | $this->setError('文件路径不正确'); |
|
| 173 | ||
| 174 | return false; |
|
| 175 | } |
|
| 176 | ||
| 177 | $data = []; |
|
| 178 | $data['media'] = '@' . realpath($file); |
|
| 179 | ||
| 180 | $node = 'uploadimg'; |
|
| 181 | ||
| 182 | $res = $this->_post($node, $data, false); |
|
| 183 | ||
| 184 | return $res; |
|
| 185 | } |
|
| 186 | ||
| 187 | /** |
|
| 188 | * 上传图文消息内的视频. |
|
| @@ 252-274 (lines=23) @@ | ||
| 249 | * |
|
| 250 | * @return string. 获取地址 http://mmbiz.qpic.cn/mmbiz/NdxGKqW8jE9GbAqUEPdSgSvbUbProSmE8NbUFwIYnp0Duibs611ZsCLza6b2dS8Ex3CO5dtv0u1HP9QY32djCxA/0 |
|
| 251 | */ |
|
| 252 | public function cardUploadimg($file) |
|
| 253 | { |
|
| 254 | if (!$file) { |
|
| 255 | $this->setError('参数缺失'); |
|
| 256 | ||
| 257 | return false; |
|
| 258 | } |
|
| 259 | ||
| 260 | if (!file_exists($file)) { |
|
| 261 | $this->setError('文件路径不正确'); |
|
| 262 | ||
| 263 | return false; |
|
| 264 | } |
|
| 265 | ||
| 266 | $data = []; |
|
| 267 | $data['buffer'] = '@' . realpath($file); |
|
| 268 | ||
| 269 | $node = 'uploadimg'; |
|
| 270 | ||
| 271 | $res = $this->_post($node, $data, false); |
|
| 272 | ||
| 273 | return $res; |
|
| 274 | } |
|
| 275 | ||
| 276 | /** |
|
| 277 | * 上传卡券logo图片. $file为 $_FILES['xxx']; |
|