/**** * 删除标签 * @param access_token * @param params * @return */ public static String deleteTags(String access_token,String params){ String update_url="https://api.weixin.qq.com/cgi-bin/tags/delete?access_token=";//删除标签接口 String jsonData = TestMenu.sendPost(update_url+access_token, params); System.out.println("请求接口返回"+jsonData); return jsonData; }
params代码
//2,删除标签参数 String params="{" +"\"tag\":{" +"\"id\" : 101" +"}}";
sendPost方法
/***V型知识库 www.vxzsk.com * Post 请求* */ public static String sendPost(String requrl,String param){ URL url; String sTotalString=""; try { url = new URL(requrl); URLConnection connection = url.openConnection(); connection.setRequestProperty("accept", "*/*"); connection.setRequestProperty("connection", "Keep-Alive"); connection.setRequestProperty("Content-Type", "text/xml"); // connection.setRequestProperty("Content-Length", body.getBytes().length+""); connection.setRequestProperty("User-Agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"); connection.setDoOutput(true); OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream(), "utf-8"); out.write(param); // 向页面传递数据。post的关键所在! out.flush(); out.close(); // 一旦发送成功,用以下方法就可以得到服务器的回应: String sCurrentLine; sCurrentLine = ""; sTotalString = ""; InputStream l_urlStream; l_urlStream = connection.getInputStream(); // 传说中的三层包装阿! BufferedReader l_reader = new BufferedReader(new InputStreamReader( l_urlStream)); while ((sCurrentLine = l_reader.readLine()) != null) { sTotalString += sCurrentLine + "\r\n"; } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println(sTotalString); return sTotalString; }
access_token http://www.vxzsk.com/28.html