Home  >  Article  >  Backend Development  >  Relevant examples involving modifications to WeChat interfaces

Relevant examples involving modifications to WeChat interfaces

零下一度
零下一度Original
2017-07-02 11:40:551521browse

This article mainly introduces the solution to the failure of sending messages after upgrading [Enterprise Official Account] to [Enterprise WeChat], involving the modification of the WeChat interface. Friends in need can refer to the following

The example in this article describes the solution to the failure to send messages after [Enterprise Official Account] is upgraded to [Enterprise WeChat]. I would like to share it with you for your reference. The details are as follows:

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 public account to send notification messages could no longer send messages.

So, I opened the upgrade message again and read it carefully: the enterprise account will be migrated to the enterprise WeChat management background (work.weixin.qq.com/login) for unified management. Previously, the management backend address of the company's public account was qy.weixin.qq.com. If I can't send messages, could it be that the interface address has also changed?

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

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 usage. illustrate. 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=\"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 in quotation marks, it will be treated as

string. So, I changed the code to a string and tried it, and it worked. . .

The above is the detailed content of Relevant examples involving modifications to WeChat interfaces. For more information, please follow other related articles on 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