Solution to the invalid access_token under PHP: 1. Use swoole to write a timer to ensure that the access_token is refreshed every hour; 2. Just write it into the database.
The operating environment of this article: windows10 system, php 7, thinkpad t480 computer.
Maybe you have encountered the same problem as me: PHP has clearly set up a cache and it has not expired, but it prompts that it has expired.
Encountering this kind of problem is generally due to two situations:
1. The access_token generated by multiple appids and secrete covers each other, so we must distinguish this situation clearly;
2. The code may generate access_token in multiple places. When a new access_token is generated, the old one will expire after 5 minutes;
If you encounter the above two situations, you can use the following Solution:
Use swoole to write a timer to ensure that the access_token is refreshed every hour and then written to the database.
Recommended learning: php training
The above is the detailed content of What to do if the access_token is invalid under PHP. For more information, please follow other related articles on the PHP Chinese website!