Tag: httparty

Net HTTP unescapes字符?

Ruby Net HTTP是否具有unescape字符(例如龅 to 龅 )? 我使用HTTParty发送请求龅 但是请求服务器上的请求参数显示为龅 。

在`require’:无法加载这样的文件 – httparty(LoadError)

我的默认ruby是2.0.0p384。 ruby脚本有: #!/usr/bin/env ruby require ‘rubygems’ require ‘httparty’ 如果上面的标题更改为: #!/usr/bin/ruby1.9.1 脚本运行正常。 /var/lib/gems/2.0.0/gems/httparty-0.13.5存在。 我无法理解为什么用2.0.0 ruby​​运行脚本会给出: /usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in require’: cannot load such file — httparty (LoadError) from usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in in`’

如何将HTTParty与UTF-8编码一起使用?

我有一个像http://example.com/tag/София/new.json这样的url,我想用HTTParty发出GET请求。 当我做: HTTPArty.get“ http://example.com/tag/София/new.json 我明白了: URI::InvalidURIError at / bad URI(is not URI?): link here 任何想法如何处理这个?

在带有HTTParty的rails应用程序中使用Postmates API

我一直在努力将Postmates与我的电子商务rails应用程序集成,以便按需交付。 我已经为测试目的构建了一个控制器和视图,并在我的路由文件中构建它(在我的开发环境中构建)。 作为参考,这里是Postmates的文档: docs ,这是一个技术博客: 博客 路线文件: resources :postmates do member do post ‘get_delivery’ end end 控制器: require ‘httparty’ require ‘json’ class PostmatesController { :dropoff_address => “205 E 95th Street, New York, NY 10128”, :pickup_address => “619 W 54th St, New York, NY 10019” }.to_json, :basic_auth => { :username => api_key }, :headers => { […]

为什么#{}没有将值添加到字符串中?

使用httparty我正在发出GET请求: https://api.marktplaats.nl/api3/categories.json?oauth_token=1me6jq76h8t6rim747m7bketkd&api_ver=3.7&session=ebc565b8-659f-40f6-9d0a-96986f1d1595&screenWidth=62&screenHeight=111&app_ver=Android3.1.0 代码A: require ‘httparty’ class Marktplaats def categories HTTParty.get(‘https://api.marktplaats.nl/api3/categories.json?oauth_token=1me6jq76h8t6rim747m7bketkd&api_ver=3.7&session=ebc565b8-659f-40f6-9d0a-96986f1d1595&screenWidth=62&screenHeight=111&app_ver=Android3.1.0’) end end 代码B: require ‘httparty’ class Marktplaats @oauth_token = ‘1me6jq76h8t6rim747m7bketkd’ def categories HTTParty.get(“https://api.marktplaats.nl/api3/categories.json?oauth_token=#{@oauth_token}&api_ver=3.7&session=ebc565b8-659f-40f6-9d0a-96986f1d1595&screenWidth=62&screenHeight=111&app_ver=Android3.1.0”) end end 做的时候: m = Marktplaats.new m.categories 代码A有效,但代码B没有。 在代码B的GET调用上调用.request.last_uri.to_s返回: https://api.marktplaats.nl/api3/categories.json?oauth_token=&api_ver=3.7&session=ebc565b8-659f-40f6-9d0a-96986f1d1595&screenWidth=62&screenHeight=111&app_ver=Android3.1.0 怎么可能出错?

发送通过HTTParty发送的post查询

我正在使用带有HTTParty的Buffer App API尝试通过/ updates / create方法添加post,但是API似乎忽略了我的“text”参数并引发了错误。 如果我在命令行上通过cURL执行它,它可以完美地工作。 这是我的代码: class BufferApp include HTTParty base_uri ‘https://api.bufferapp.com/1’ def initialize(token, id) @token = token @id = id end def create(text) BufferApp.post(‘/updates/create.json’, :query => {“text” => text, “profile_ids[]” => @id, “access_token” => @token}) end end 我正在运行这样的方法: BufferApp.new(‘{access_token}’, ‘{profile_id}’).create(‘{Text}’) 我已经将debug_output $stdout添加到了类中,它似乎发布了OK: POST /1/updates/create.json?text=Hello%20there%20why%20is%20this%20not%20working%3F&profile_ids[]={profile_id}&access_token={access_token} HTTP/1.1\r\nConnection: close\r\nHost: api.bufferapp.com\r\n\r\n” 但是我收到了一个错误。 我错过了什么吗?

Rails使用API

我是初学者,正在使用API​​。 我正在尝试使用Forecast API 。 我不想使用它的官方包装 ,因为我首先喜欢学习和学习。 class Forecast include HTTParty base_uri “api.forecast.io/forecast/#{@api_key}/#{@latitude},#{@longitude}” def initialize(api_key,latitude,longitude) self.api_key = api_key self.latitude = latitude self.longitude = longitude end end 现在初始化后的下一步应该是什么。 我试图理解使用httparty gem示例,但无法弄清楚究竟要做什么。 你能帮我解决一下并用API指出相关资源吗?

使用HTTParty进行非常基本的Rails 4.1 API调用

Rails相对较新。 我试图调用一个API,它应该返回一个唯一的URL给我。 我在我的应用程序上捆绑了HTTParty。 我已经创建了一个UniqueNumber控制器,我已经阅读了几个HTTParty指南,只要我想要的东西,但也许我只是有点迷失,真的不知道该怎么做。 基本上,我需要做的就是调用API,获取它返回的URL,然后将该URL插入到用户的数据库中。 有人能指出我正确的方向或与我分享一些代码吗?

麻烦包括在铁轨上的ruby中的httparty

我一直在尝试在rails代码中使用HTTParty sudo gem install httparty 从命令行我现在可以成功地做到 httparty “http://twitter.com/statuses/public_timeline.json” 当我在我的rails应用程序中尝试此操作时 require ‘rubygems’ require ‘httparty’ class FooController < ApplicationController include HTTParty def bar blah = HTTParty.get("http://twitter.com/statuses/public_timeline.json") end end 我收到错误消息“没有这样的文件加载 – httparty” 我怀疑我的环境有问题吗?

HTTParty的内存问题并下载大文件

这是否会导致Ruby的内存问题。 我知道如果大小超过10KB,Open-URI会写入TempFile。 但HTTParty会在写入TempFile之前尝试将整个PDF保存到内存中吗? src = Tempfile.new(“file.pdf”) src.binmode src.write HTTParty.get(“large_file.pdf”).parsed_response