Method: WechatGate::Tokens::Ext#write_token_to_file

Defined in:
lib/wechat_gate/tokens/ext.rb

#write_token_to_file(current_page_url, output_type) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/wechat_gate/tokens/ext.rb', line 30

def write_token_to_file current_page_url, output_type
  params = generate_js_request_params(current_page_url)
  case output_type
  when /\// # write to file
    f = File.open(output_type, 'w')
    f.write %Q{<script>var wxServerConfig = #{params.to_json}</script>}
    f.close
  when 'ruby'
    params
  when 'js'
    params.to_json
  else
    params
  end
end