search

Home  >  Q&A  >  body text

How to encapsulate the code for WeChat development curl to perform WeChat interface operations?

Hello everyone, when I was doing WeChat development, I encapsulated a curl method according to the teacher's video to operate the WeChat interface, but there was a problem during the actual operation. When calling this Before the method, all data can be output normally, but after calling this method, the data cannot be output, and the report is: "errcode":40001,"errmsg":"invalid credential, access_token is invalid or not latest hint: [7Gvnoa0808vr46 !]" error, could you please help me find out if there is anything wrong with the curl method I wrote? Why does it report an error as soon as it is executed?


LRTRLLRTRL2778 days ago1227

reply all(2)I'll reply

  • 清晨的那一抹阳光照耀在我的脸上

    清晨的那一抹阳光照耀在我的脸上2017-05-19 10:06:48

    First make sure the appid and secret are correct, and then check whether the access_token exceeds the request limit (up to 2000 times a day). It is best to add the access_token request to the cache or SESSION, otherwise the upper limit will be reached after just testing in one day

    reply
    0
  • LRTRL

    The appid and appsecret are both correct, and I put the obtained access_token in the database, which will be judged before calling; but how do I put it in the session? I also put it in the session before, but other interfaces call this During the session, the value cannot be obtained.

    LRTRL · 2017-05-26 16:11:05
    清晨的那一抹阳光照耀在我的脸上

    Your other interface calls will definitely not work, and you must request the token again.

    清晨的那一抹阳光照耀在我的脸上 · 2017-05-27 16:28:59
  • PHP中文网

    PHP中文网2017-05-19 10:05:28

    The token is cached. It may be that two tokens are generated locally and online, causing one to expire

    reply
    0
  • Cancelreply