Good day! I wrote a script for automatic unloading of goods from the online store to photo albums and products in VK. Worn out, but the script works, everything is ok. Next, I need to write a cron, which will periodically update the information about the goods. When authorizing a user, he set scope offline so that the token is not limited by time.
At the first export, the user is authenticated and received a token. After the user confirms the access rights, the user data, including the token itself, I save to the database.
Further, when updating product information, I need to automatically update the product description, or photos (depending on which type of export the user has selected) using the crown. And here there was a problem: how to check if the token is valid? secure.checkToken returns an error when I try to check access_token: User authorization failed: invalid access_token
$params = array( 'uids' => $user_id, 'access_token' => $token ); $result = json_decode(file_get_contents('https://api.vk.com/method/secure.checkToken' . '?' . urldecode(http_build_query($params))), true);