Skip to content

Instantly share code, notes, and snippets.

@lajunta
Created November 18, 2013 06:47
Show Gist options
  • Save lajunta/7523651 to your computer and use it in GitHub Desktop.
Save lajunta/7523651 to your computer and use it in GitHub Desktop.
#encoding: utf-8
require "net/http"
require "json"
require "xmlsimple"
def get_access_token
appid="your appid"
appsecret="your appsecret"
uri_string="https://api.yixin.im/cgi-bin/token?grant_type=client_credential&appid=#{appid}&secret=#{appsecret}"
uri=URI.parse(uri_string)
res = Net::HTTP.get(uri)
hsh = JSON.parse(res)
hsh["access_token"]
end
access_token=get_access_token
uri_string="https://api.yixin.im/cgi-bin/menu/get?access_token=#{access_token}"
uri=URI.parse(uri_string)
res = Net::HTTP.get(uri)
hsh = JSON.parse(res)
#hsh=XmlSimple.xml_in(res)
puts hsh["menu"]["button"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment