简体   繁体   English

来自具有永久access_token的Rails应用的GET请求

[英]GET request from rails app with permanent access_token

I wish to access a web services api from within a rails application and display the data from the api. 我希望从Rails应用程序中访问Web服务api并显示api中的数据。 The api uses a permanent access_token and a parameter full_access=true. api使用永久的access_token和参数full_access = true。 So the url i wish to access is similar to 因此,我希望访问的网址类似于

http://.......com/lists.json?access_token=d10884g521fc4dc964fd9v06a9121f63&full_access=true

I'm having trouble creating a simple get request which includes the access_token so any advice would be helpful. 我在创建包含access_token的简单get请求时遇到了麻烦,因此任何建议都将有所帮助。 Can I use a simple get request or do I need to implement oauth2? 我可以使用简单的get请求还是需要实现oauth2?

If so a sample of a very simple client would be helpful 如果是这样的话,一个非常简单的客户样本会有所帮助

You can use the Net::HTTP class: 您可以使用Net :: HTTP类:

require 'net/http'

url = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(url.path)
res = Net::HTTP.start(url.host, url.port) {|http|
  http.request(req)
}
puts res.body

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM