转换或执行Rails应用程序的CURL请求 [英] Convert or Execute an CURL Request for Rails Application

查看:51
本文介绍了转换或执行Rails应用程序的CURL请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Ruby on Rails控制器中执行以下请求?

How can I execute the following request in my Ruby on Rails controllers?

curl -X POST \
 -F "id={object-url OR object-id}" \
 -F "scrape=true" \
 -F "access_token={your access token}" \
 "https://graph.facebook.com"

推荐答案

使用 rest-client gem .您可以使用此方法从您的控制器发出HTTP请求. 他们的github页面上有示例,说明了如何与参数一起发出请求. 一个简单的get请求可能看起来像这样:

Use the rest-client gem.You can make HTTP request from your controller using this. Their github page has examples explaining how to make reuqest along with paramters. A simple get request may look like this:

RestClient.get '"https://graph.facebook.com', {params: {'scrape'=> true, 'access_token' => 'your_access_token'}}

这篇关于转换或执行Rails应用程序的CURL请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆