I have a wechat service account with a User Defined menu interface that responds with rich media messages. The menu and the responses function but are slow and a bit hit and miss. I have noticed a similar hit and miss effect when deploying my server config to wechat. All this makes my menu responses clunky and rather useless at times. I'm using if..else statements as they give the best results in the hit/miss part but as the menu is large it ttakes a painfully long time. here is a sample of the most reliable way of processing my menu events in PHP
$body = file_get_contents('php://input');
$obj = simplexml_load_string($body);
$key = $obj->EventKey;
$fromUser=$obj->FromUserName;
$toUser=$obj->ToUserName;
if($key == "button_001"){
//respond to the event
}else if($key == "button_002"){
//respond to the event
}
I've left out the verification as it is the same as it is in the tutorials and documentation. any help would be appreciated.
I've encountered similar problem with just the response messages (no menu). I don't get why my solution works, but what fixed the problem for me was to
1) comment out the responseMsg() code and validate through wechat,
2) then, comment out the valid() code and uncomment out my responseMsg() line.
3) magically, I have no more hit-or-miss, and no delay in responses...
1.
$wechatObj->valid();
//$wechatObj->responseMsg();
1a.validate code through wechat backend
2.save code back as this for live deployment:
//$wechatObj->valid();
$wechatObj->responseMsg();