Home  >  Article  >  WeChat Applet  >  Error errcode 40054 occurs when creating a new button in WeChat development

Error errcode 40054 occurs when creating a new button in WeChat development

高洛峰
高洛峰Original
2017-02-28 09:36:432704browse

When developing a button to create a new official account on WeChat, the following error was reported:

{errcode:40054,errmsg:"invalid sub button url domain"}

After careful investigation, it was found that it was url Wrong address format:

		WXButton button = new WXButton();
		button.setName("baidu");
		button.setType("view");
		button.setUrl("www.baidu.com");
		
		WXButton button2 = new WXButton();
		button2.setName("客服MM");
		button2.setType("view");
		button2.setUrl("www.baidu.com");
		
		WXButton button3 = new WXButton();
		button3.setName("帮助");
		button3.setType("view");
		button3.setUrl("www.baidu.com");

Here button.setUrl("www.baidu.com"); should be changed to: button.setUrl("http:// www.baidu.com");

Be sure to bring the http prefix, otherwise an error will be reported {errcode:40054,errmsg:"invalid sub button url domain"}

Related WXButton.java code As follows:

public class WXButton 
{
	private String type;	// 按钮菜单的响应动作类型,该字段始终不能为空
	private String name;	// 按钮菜单标题,不超过16个字节,子菜单不超过40个字节,该字段始终不能为空
	
	private String key;	// 点击按钮时事件的key,该字段在 click等点击类型不能为空
	private String url;	// 网页链接,用户点击菜单可打开链接,不超过256字节,该字段在  view类型不能为空
	
	private WXButton[] sub_button;	// 子按钮(按钮最多有二级,第一级按钮最多三个,每一个一级按钮下面的二级按钮最多五个)
	
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getKey() {
		return key;
	}
	public void setKey(String key) {
		this.key = key;
	}
	public WXButton[] getSub_button() {
		return sub_button;
	}
	public void setSub_button(WXButton[] sub_button) {
		this.sub_button = sub_button;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
}

For more WeChat development, the new button reports error errcode 40054. For related articles, please pay attention to the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn