eric_weixin 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,18 +0,0 @@
1
- # 二维码
2
- module EricWeixin::TwoDimensionCode
3
- # 长URL转短URL
4
- # ===参数说明:
5
- # * app_id 微信公众账号的app_id
6
- # * url 需要转短url的链接
7
- # ===调用示例:
8
- # EricWeixin::TwoDimensionCode.short_url app_id: 'wx4564afc37fac0ebf', url: 'http://mp.weixin.qq.com/wiki/10/165c9b15eddcfbd8699ac12b0bd89ae6.html'
9
- def self.short_url options
10
- access_token = EricWeixin::AccessToken.get_valid_access_token_by_app_id app_id: options[:app_id]
11
- url = "https://api.weixin.qq.com/cgi-bin/shorturl?access_token=#{access_token}"
12
- pp url
13
- response = RestClient.post url, {action: "long2short", long_url: options[:url]}
14
- response = JSON.parse(response.body)
15
- pp response
16
- response["short_url"]
17
- end
18
- end