lib/blsm-mp-wx.rb in blsm-mp-wx-0.3.0 vs lib/blsm-mp-wx.rb in blsm-mp-wx-0.3.2
- old
+ new
@@ -195,16 +195,12 @@
return nil unless access_token
response = Faraday.new(:url => 'https://api.weixin.qq.com').post do |req|
req.url '/cgi-bin/shorturl'
req.headers['Content-Type'] = 'application/json'
- data = {
- action: 'long2short',
- long_url: long_url
- }
req.params[:long_url] = long_url
req.params[:access_token] = access_token
- req.body = data.to_json
+ req.body = "{\"action\":\"long2short\",\"long_url\":\"#{long_url}\"}"
end
json_obj = parse_json(response.body)
return nil unless json_obj
return nil unless json_obj.has_key?('short_url')