Anu*_*rag 8 ruby json ruby-on-rails
如何通过我的ruby on rails代码中的URL获取JSON对象:
url = "https://graph.facebook.com/me/friends?access_token=XXX"
Run Code Online (Sandbox Code Playgroud)
我无法在rails上获得JSON + Ruby的优秀教程.有人可以帮我谢谢.
M. *_*her 27
require 'open-uri'
require 'json'
json_object = JSON.parse(open("https://graph.facebook.com/me/friends?access_token=XXX").read)
Run Code Online (Sandbox Code Playgroud)
这是最简单的方法,虽然它可能不是最快的.
编辑:如果URI的参数字符串中包含特殊字符,则必须首先对其进行转义/编码URI.escape.
| 归档时间: |
|
| 查看次数: |
7268 次 |
| 最近记录: |