Get the App
SLTechnology News&Howtos  ›  Development  › 

How to understand Wechat getAccessToken

Shulou Source: shulou.com Published: 2022-06-03 08:54:08 11月15日 Update

This article introduces the relevant knowledge of "how to understand Wechat getAccessToken". In the operation of practical cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Memcache cache stores user information for 7000 seconds

File storage access_token

Function getAccessToken () {/ / access_token should be stored and updated globally, the following code to write to a file for example $data = json_decode (file_get_contents ("access_token.json")); if ($data- > expire_time)

< time()) { $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$this->

AppId&secret=$this- > appSecret "; $res = json_decode ($this- > httpGet ($url)); $access_token = $res- > access_token; if ($access_token) {$data- > expire_time = time () + 7000; $data- > access_token = $access_token; $fp = fopen (" access_token.json "," w "); fwrite ($fp, json_encode ($data)); fclose ($fp);} else {$access_token = $data- > access_token } return $access_token;} "how to understand Wechat getAccessToken" ends here. Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Storage content files more knowledge practical learned next code information global dilemma actual situation articles cases users examples cache tape Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Apple Shulou Technology Redmi Shulou Tech Info