mirror of
				https://gitee.com/zoujingli/WeChatDeveloper.git
				synced 2025-10-27 00:12:08 +08:00 
			
		
		
		
	
						commit
						b6c6ace829
					
				
							
								
								
									
										134
									
								
								WeChat/Draft.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										134
									
								
								WeChat/Draft.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,134 @@ | ||||
| <?php | ||||
| 
 | ||||
| // +----------------------------------------------------------------------
 | ||||
| // | WeChatDeveloper
 | ||||
| // +----------------------------------------------------------------------
 | ||||
| // | 版权所有 2014~2020 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
 | ||||
| // +----------------------------------------------------------------------
 | ||||
| // | 官方网站: http://think.ctolog.com
 | ||||
| // +----------------------------------------------------------------------
 | ||||
| // | 开源协议 ( https://mit-license.org )
 | ||||
| // +----------------------------------------------------------------------
 | ||||
| // | github开源项目:https://github.com/zoujingli/WeChatDeveloper
 | ||||
| // +----------------------------------------------------------------------
 | ||||
| 
 | ||||
| namespace WeChat; | ||||
| 
 | ||||
| use WeChat\Contracts\BasicWeChat; | ||||
| use WeChat\Exceptions\InvalidResponseException; | ||||
| 
 | ||||
| /** | ||||
|  * 微信草稿箱管理 | ||||
|  * Class Draft | ||||
|  * @author taoxin | ||||
|  * @package WeChat | ||||
|  */ | ||||
| class Draft extends BasicWeChat | ||||
| { | ||||
|     /** | ||||
|      * 新建草稿 | ||||
|      * @param $articles | ||||
|      * @return array | ||||
|      * @throws Exceptions\LocalCacheException | ||||
|      * @throws InvalidResponseException | ||||
|      */ | ||||
|     public function add($articles) | ||||
|     { | ||||
|         $url = "https://api.weixin.qq.com/cgi-bin/draft/add?access_token=ACCESS_TOKEN"; | ||||
|         return $this->httpPostForJson($url, ['articles' => $articles]); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 获取草稿 | ||||
|      * @param string $media_id | ||||
|      * @param string $outType 返回处理函数 | ||||
|      * @return array|string | ||||
|      * @throws Exceptions\LocalCacheException | ||||
|      * @throws InvalidResponseException | ||||
|      */ | ||||
|     public function get($media_id, $outType = null) | ||||
|     { | ||||
|         $url = "https://api.weixin.qq.com/cgi-bin/draft/get?access_token=ACCESS_TOKEN"; | ||||
|         $this->registerApi($url, __FUNCTION__, func_get_args()); | ||||
|         return $this->httpPostForJson($url, ['media_id' => $media_id]); | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * 删除草稿 | ||||
|      * @param string $media_id | ||||
|      * @return array | ||||
|      * @throws Exceptions\LocalCacheException | ||||
|      * @throws InvalidResponseException | ||||
|      */ | ||||
|     public function delete($media_id) | ||||
|     { | ||||
| 
 | ||||
|         $url = "https://api.weixin.qq.com/cgi-bin/draft/delete?access_token=ACCESS_TOKEN"; | ||||
|         $this->registerApi($url, __FUNCTION__, func_get_args()); | ||||
| 
 | ||||
|         return $this->httpPostForJson($url, ['media_id' => $media_id]); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 新增图文素材 | ||||
|      * @param array $data 文件名称 | ||||
|      * @return array | ||||
|      * @throws Exceptions\LocalCacheException | ||||
|      * @throws InvalidResponseException | ||||
|      */ | ||||
|     public function addNews($data) | ||||
|     { | ||||
|         $url = "https://api.weixin.qq.com/cgi-bin/material/add_news?access_token=ACCESS_TOKEN"; | ||||
|         $this->registerApi($url, __FUNCTION__, func_get_args()); | ||||
|         return $this->httpPostForJson($url, $data); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 修改草稿 | ||||
|      * @param string $media_id 要修改的图文消息的id | ||||
|      * @param int $index 要更新的文章在图文消息中的位置(多图文消息时,此字段才有意义),第一篇为0 | ||||
|      * @param $articles | ||||
|      * @return array | ||||
|      * @throws Exceptions\LocalCacheException | ||||
|      * @throws InvalidResponseException | ||||
|      */ | ||||
|     public function update($media_id, $index, $articles) | ||||
|     { | ||||
|         $data = ['media_id' => $media_id, 'index' => $index, 'articles' => $articles]; | ||||
|         $url = "https://api.weixin.qq.com/cgi-bin/draft/update?access_token=ACCESS_TOKEN"; | ||||
|         $this->registerApi($url, __FUNCTION__, func_get_args()); | ||||
|         return $this->httpPostForJson($url, $data); | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * 获取草稿总数 | ||||
|      * @return array | ||||
|      * @throws Exceptions\LocalCacheException | ||||
|      * @throws InvalidResponseException | ||||
|      */ | ||||
|     public function getCount() | ||||
|     { | ||||
|         $url = "https://api.weixin.qq.com/cgi-bin/draft/count?access_token=ACCESS_TOKEN"; | ||||
|         $this->registerApi($url, __FUNCTION__, func_get_args()); | ||||
|         return $this->httpGetForJson($url); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 获取草稿列表 | ||||
|      * @param int $offset 从全部素材的该偏移位置开始返回,0表示从第一个素材返回 | ||||
|      * @param int $count 返回素材的数量,取值在1到20之间 | ||||
|      * @param int $no_content 1 表示不返回 content 字段,0 表示正常返回,默认为 0 | ||||
|      * @return array | ||||
|      * @throws Exceptions\LocalCacheException | ||||
|      * @throws InvalidResponseException | ||||
|      */ | ||||
|     public function batchGet($offset = 0, $count = 20, $no_content = 0) | ||||
|     { | ||||
|         $url = "https://api.weixin.qq.com/cgi-bin/draft/batchget?access_token=ACCESS_TOKEN"; | ||||
|         $this->registerApi($url, __FUNCTION__, func_get_args()); | ||||
|         return $this->httpPostForJson($url, ['no_content' => $no_content, 'offset' => $offset, 'count' => $count]); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user