Recently, I saw news that WeChat upgraded corporate public accounts to corporate WeChat. I didn't care about it at the time, but later I discovered that the program that used the interface of the company's official account to send notification messages could no longer send messages. This article will share with you the reasons and solutions for failure to send messages after the corporate official account is upgraded to corporate WeChat.
Log in to the new backend and check it out, and find that the Secret value of the application has changed, with fewer digits than before. After replacing the Secret value in the code with a new one, I found that it still didn't work. After debugging, I found an error when using the post request to call the interface to send a message: {"errcode":-1,"errmsg":"Invalid input"}. There may be two reasons for the analysis: the address of the message sending interface called is wrong; or the format of the post parameters passed is wrong.
Fortunately, I found the API documentation for Enterprise WeChat on its official website: https://work.weixin.qq.com/api/doc, which has more detailed instructions for use. It was confirmed that the URL address of the calling interface has not changed (https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=ACCESS_TOKEN is still used to send messages). However, I found that the format of the text message is a little different. The official website example is as follows:
{ "touser" : "UserID1|UserID2|UserID3", "toparty" : " PartyID1|PartyID2 ", "totag" : " TagID1 | TagID2 ", "msgtype" : "text", "agentid" : 1, "text" : { "content" : "你的快递已到,请携带工卡前往邮件中心领取。\n出发前可查看<a href=\"http://work.weixin.qq.com\">邮件中心视频实况</a>,聪明避开排队。" } }
I should have passed the above UserID and PartyID as numerical values, but the example is If it is placed within quotation marks, it will be treated as a string. So, I changed the code to a string and tried it, and it worked. . .
Related recommendations:
Enterprise WeChat public platform API interface development 3G website_PHP tutorial
The above is the detailed content of Reasons why message sending fails after the enterprise public account is upgraded to Enterprise WeChat. For more information, please follow other related articles on the PHP Chinese website!