{"action":"created","issue":{"url":"https://api.github.com/repos/overtrue/wechat/issues/129","labels_url":"https://api.github.com/repos/overtrue/wechat/issues/129/labels{/name}","comments_url":"https://api.github.com/repos/overtrue/wechat/issues/129/comments","events_url":"https://api.github.com/repos/overtrue/wechat/issues/129/events","html_url":"https://github.com/overtrue/wechat/issues/129","id":112071873,"number":129,"title":"多次遇到 accesstoken 无效的问题","user":{"login":"justocean","id":472133,"avatar_url":"https://avatars.githubusercontent.com/u/472133?v=3","gravatar_id":"","url":"https://api.github.com/users/justocean","html_url":"https://github.com/justocean","followers_url":"https://api.github.com/users/justocean/followers","following_url":"https://api.github.com/users/justocean/following{/other_user}","gists_url":"https://api.github.com/users/justocean/gists{/gist_id}","starred_url":"https://api.github.com/users/justocean/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justocean/subscriptions","organizations_url":"https://api.github.com/users/justocean/orgs","repos_url":"https://api.github.com/users/justocean/repos","events_url":"https://api.github.com/users/justocean/events{/privacy}","received_events_url":"https://api.github.com/users/justocean/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-10-19T04:58:25Z","updated_at":"2015-10-19T05:55:45Z","closed_at":"2015-10-19T05:08:51Z","body":"[Wechat]获取access_token时AppSecret错误，或者access_token无效。请开发者认真比对AppSecret的正确性，或查看是否正在为恰当的公众号调用接口\r\n\r\n近一周使用您的 sdk，多次遇到这个问题。后来我将access_token、api_ticket、jsapi_ticket 的 expire_at 都改成了返回的 expire_in - 200 秒，也就是官方给出的 sdk 中的7000秒\r\n\r\n今天又出现了这个问题，比较疑惑。"},"comment":{"url":"https://api.github.com/repos/overtrue/wechat/issues/comments/149109476","html_url":"https://github.com/overtrue/wechat/issues/129#issuecomment-149109476","issue_url":"https://api.github.com/repos/overtrue/wechat/issues/129","id":149109476,"user":{"login":"justocean","id":472133,"avatar_url":"https://avatars.githubusercontent.com/u/472133?v=3","gravatar_id":"","url":"https://api.github.com/users/justocean","html_url":"https://github.com/justocean","followers_url":"https://api.github.com/users/justocean/followers","following_url":"https://api.github.com/users/justocean/following{/other_user}","gists_url":"https://api.github.com/users/justocean/gists{/gist_id}","starred_url":"https://api.github.com/users/justocean/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justocean/subscriptions","organizations_url":"https://api.github.com/users/justocean/orgs","repos_url":"https://api.github.com/users/justocean/repos","events_url":"https://api.github.com/users/justocean/events{/privacy}","received_events_url":"https://api.github.com/users/justocean/received_events","type":"User","site_admin":false},"created_at":"2015-10-19T05:55:45Z","updated_at":"2015-10-19T05:55:45Z","body":"这里我觉得可能不是这个时间的问题。\r\n我觉得有可能是并发导致写这个保存 accesstoken 的文件引起的。\r\n\r\n因为您用的是 file_put_contents 这个函数，我建议是加上参数 LOCK_EX：\r\n\r\nif (!file_put_contents($this->getCacheFile($key), serialize($data), LOCK_EX))\r\n            throw new Exception('Access toekn 缓存失败');\r\n\r\n同时我也在用 redis 来保存进行测试。"}}