Method: Wechat::Api::Client#refresh

Defined in:
lib/wechat/api/client.rb

#refreshObject



39
40
41
42
43
44
45
46
47
# File 'lib/wechat/api/client.rb', line 39

def refresh
  url = format('%stoken', API_BASE)
  resp = connection.get(url, token_params)
  response = MultiJson.load(resp.body)
  return handle_error(response) if response['errcode']
  @access_token = response['access_token']
  File.open(@token_file, 'w') { |f| f.write(resp.body) } if token
  @access_token
end