码迷,mamicode.com
首页 > 其他好文 > 详细

rest-client restclient get post写法

时间:2018-08-12 14:21:25      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:https   lex   enc   weixin   color   str   grant   com   data   

get

url = "https://api.weixin.qq.com/sns/jscode2session"
    data = {
      appid: "××××", 
      secret: "×××××",
      js_code: params[:code].to_s,
      grant_type: authorization_code
    }
    response = RestClient.get url, params: data, :accept => :json
    body = JSON.parse(response.body)

post

url = "https://aip.baidubce.com/rpc/2.0/nlp/v1/lexer?access_token=××××××"
posts = {text: "8888"}
posts.encode! "GBK", "UTF-8"//如果需要编码再用这个 res = RestClient.post url, posts, :content_type => "application/json", :accept => :json res.encode! "UTF-8", "GBK" res = JSON.parse(res.body)

 

rest-client restclient get post写法

标签:https   lex   enc   weixin   color   str   grant   com   data   

原文地址:https://www.cnblogs.com/znsongshu/p/9462352.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!