|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the overtrue/wechat. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) overtrue <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* This source file is subject to the MIT license that is bundled |
|
9
|
|
|
* with this source code in the file LICENSE. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* MediaPress.php. |
|
14
|
|
|
* |
|
15
|
|
|
* Part of Overtrue\WeChat. |
|
16
|
|
|
* |
|
17
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
18
|
|
|
* file that was distributed with this source code. |
|
19
|
|
|
* |
|
20
|
|
|
* @author mingyoung <[email protected]> |
|
21
|
|
|
* @copyright 2017 |
|
22
|
|
|
* |
|
23
|
|
|
* @see https://github.com/overtrue |
|
24
|
|
|
* @see http://overtrue.me |
|
25
|
|
|
*/ |
|
26
|
|
|
|
|
27
|
|
|
namespace EasyWeChat\MediaPress; |
|
28
|
|
|
|
|
29
|
|
|
use EasyWeChat\Core\AbstractAPI; |
|
30
|
|
|
use EasyWeChat\Core\Exceptions\InvalidArgumentException; |
|
31
|
|
|
|
|
32
|
|
|
class MediaPress extends AbstractAPI |
|
33
|
|
|
{ |
|
34
|
|
|
use ManageComments, ManageCommentReplies; |
|
35
|
|
|
|
|
36
|
|
|
const API_OPEN_COMMENT = 'https://api.weixin.qq.com/cgi-bin/comment/open'; |
|
37
|
|
|
const API_CLOSE_COMMENT = 'https://api.weixin.qq.com/cgi-bin/comment/close'; |
|
38
|
|
|
const API_LIST_COMMENT = 'https://api.weixin.qq.com/cgi-bin/comment/list'; |
|
39
|
|
|
const API_MARK_ELECT = 'https://api.weixin.qq.com/cgi-bin/comment/markelect'; |
|
40
|
|
|
const API_UNMARK_ELECT = 'https://api.weixin.qq.com/cgi-bin/comment/unmarkelect'; |
|
41
|
|
|
const API_DELETE_COMMENT = 'https://api.weixin.qq.com/cgi-bin/comment/delete'; |
|
42
|
|
|
const API_REPLY_COMMENT = 'https://api.weixin.qq.com/cgi-bin/comment/reply/add'; |
|
43
|
|
|
const API_DELETE_REPLY = 'https://api.weixin.qq.com/cgi-bin/comment/reply/delete'; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @var array |
|
47
|
|
|
*/ |
|
48
|
|
|
protected $mediaPress; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Select an article. |
|
52
|
|
|
* |
|
53
|
|
|
* @param int $dataId |
|
54
|
|
|
* @param int $index |
|
55
|
|
|
* |
|
56
|
|
|
* @return $this |
|
57
|
|
|
*/ |
|
58
|
8 |
|
public function select($dataId, $index = null) |
|
59
|
|
|
{ |
|
60
|
8 |
|
$this->mediaPress = [ |
|
61
|
8 |
|
'msg_data_id' => $dataId, |
|
62
|
8 |
|
'index' => $index, |
|
63
|
|
|
]; |
|
64
|
|
|
|
|
65
|
8 |
|
return $this; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Return the media-press. |
|
70
|
|
|
* |
|
71
|
|
|
* @return array |
|
72
|
|
|
* |
|
73
|
|
|
* @throws \EasyWeChat\Core\Exceptions\InvalidArgumentException |
|
74
|
|
|
*/ |
|
75
|
8 |
|
public function mediaPress() |
|
|
|
|
|
|
76
|
|
|
{ |
|
77
|
8 |
|
if ($this->mediaPress) { |
|
|
|
|
|
|
78
|
8 |
|
return $this->mediaPress; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
throw new InvalidArgumentException('Missing media-press data.'); |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|