All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sf.weixinmp.saas.dialog.base.uienrich.CreateMenuRequest Maven / Gradle / Ivy

The newest version!
package net.sf.weixinmp.saas.dialog.base.uienrich;

import java.nio.charset.UnsupportedCharsetException;

import net.sf.weixinmp.model.Menu;
import net.sf.weixinmp.saas.WeixinmpRequest;

import org.apache.http.HttpEntity;
import org.apache.http.entity.StringEntity;

/**
 * 创建菜单
 * @author Alex
 *
 */
public class CreateMenuRequest extends WeixinmpRequest {
	//http://mp.weixin.qq.com/wiki/13/43de8269be54a0a6f64413e4dfa94f39.html
	public String execute(String accessToken, Menu menu) {
		HttpEntity entity;
		try {
			entity = new StringEntity(menu.toString(), "UTF-8");
			return this.requestContentStringURLConnection("/menu/create?access_token="+accessToken, "POST", menu.toString());
		} catch (UnsupportedCharsetException e) {
			return "{\"errcode\":50003,\"errmsg\":\""+e.getLocalizedMessage()+"\"}";
		}

	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy