首页 > 其他 > 详细

rest-client restclient get post写法

时间:2018-08-12 12:43:57      阅读:218      评论:0      收藏:0      [点我收藏+]

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://www.cnblogs.com/znsongshu/p/9462352.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!