package com.cnd3b.utility.qywechat.tools.media_manage;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

import com.cnd3b.utility.qywechat.base.GetAccessToken;

/**
 * 删除永久素材
 * 
 * @author Administrator
 * 
 */
public class Delete {
	String result="";
	public Delete(String appid, String MediaId) throws IOException {
		URL url = new URL(
				"https://qyapi.weixin.qq.com/cgi-bin/material/del?access_token="
						+ GetAccessToken.get() + "&agentid=" + appid
						+ "&media_id=" + MediaId);
		URLConnection connection = url.openConnection();
		// 获取媒体文件上传的输入流（从微信服务器读数据）
		BufferedReader in = new BufferedReader(new InputStreamReader(
				connection.getInputStream()));
		StringBuffer content = new StringBuffer();
		String line = null;
		while ((line = in.readLine()) != null) {
			content.append(line);
		}
		in.close();
		// 测试打印结果 
		result= content.toString();
	}
	public String getResult(){
		return result;
	}
}
