httparty

Rails working with API

泄露秘密 提交于 2019-12-06 11:45:32
问题 I am beginner in working with API. I'm trying to work with the Forecast API. I don't want to use its official wrapper, because first I like to study and learn. 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 Now what should be the next step after initialization. I've tried to understand using the httparty gem

Sending array variables using HTTParty

寵の児 提交于 2019-12-06 10:59:30
问题 I'm sending a POST request using HTTParty. One of the variables required is an array. This is the code I'm using to send: response = HTTParty.post url, :body => {"key"=>'XYZ123', "content"=> [{"placename"=>"placeholder", "placecontent"=>"sample content"}], etc. } The API needs to see: "content": [ { "placename": "placeholder", "placecontent": "sample content" } ], However, when I check the request received logs on the API, I see that my code is producing: "content": [ { "placename":

Very Basic Rails 4.1 API Call using HTTParty

此生再无相见时 提交于 2019-12-06 02:11:57
问题 Relatively new to Rails. I am trying to call an API and it's supposed to return a unique URL to me. I have HTTParty bundled on my app. I have created a UniqueNumber controller and I have read through several HTTParty guides as far as what I want but maybe I'm just a bit lost and really have no idea what to do. Basically, all I need to do is call the API, get the URL it returns, then insert that URL into the database for a user. Can anyone point me in the right direction or share some code

Sending a post query sent via HTTParty

喜欢而已 提交于 2019-12-06 00:57:41
I'm working with the Buffer App API with HTTParty to try and add posts via the /updates/create method, but the API seems to ignore my "text" parameter and throws up an error. If I do it via cURL on the command line it works perfectly. Here's my code: 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 And I'm running the method like this: BufferApp.new('{access_token}', '{profile

Trouble including httparty in ruby on rails

浪子不回头ぞ 提交于 2019-12-05 10:21:28
问题 I've been trying to use HTTParty in my rails code sudo gem install httparty From the command line I can now successfully do httparty "http://twitter.com/statuses/public_timeline.json" When I try this in my rails app require 'rubygems' require 'httparty' class FooController < ApplicationController include HTTParty def bar blah = HTTParty.get("http://twitter.com/statuses/public_timeline.json") end end I get the error message "no such file to load -- httparty" I suspect there is something wrong

Rails HTTParty Getting Timeout::Error

落爺英雄遲暮 提交于 2019-12-04 20:18:42
I have an API centric application (/api/v1/users) it simply return all users restfully with JSON format. My problem is, if I call that route on the controller, it returns "Timeout::Error" What is the problem? class BaseController < ApplicationController def index return HTTParty.get('http://localhost:3000/api/v1/users').body end end Update users_controller.rb (/api/v1/users) application_controller.rb https://gist.github.com/4359591 Logs http://pastie.org/5565618 If I understand correctly, you have an API end-point, at /api/v1/users , and your BaseController#index is calling that method? If

Rails working with API

♀尐吖头ヾ 提交于 2019-12-04 16:43:14
I am beginner in working with API. I'm trying to work with the Forecast API . I don't want to use its official wrapper , because first I like to study and learn. 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 Now what should be the next step after initialization. I've tried to understand using the httparty gem examples, but cant figure out what exactly to do. Could you help me to fix it & point related

Very Basic Rails 4.1 API Call using HTTParty

依然范特西╮ 提交于 2019-12-04 07:25:37
Relatively new to Rails. I am trying to call an API and it's supposed to return a unique URL to me. I have HTTParty bundled on my app. I have created a UniqueNumber controller and I have read through several HTTParty guides as far as what I want but maybe I'm just a bit lost and really have no idea what to do. Basically, all I need to do is call the API, get the URL it returns, then insert that URL into the database for a user. Can anyone point me in the right direction or share some code with me? Let's assume the API is in a JSON format and returns the data like so: {"url": "http://example

Trouble including httparty in ruby on rails

99封情书 提交于 2019-12-03 22:37:50
I've been trying to use HTTParty in my rails code sudo gem install httparty From the command line I can now successfully do httparty "http://twitter.com/statuses/public_timeline.json" When I try this in my rails app require 'rubygems' require 'httparty' class FooController < ApplicationController include HTTParty def bar blah = HTTParty.get("http://twitter.com/statuses/public_timeline.json") end end I get the error message "no such file to load -- httparty" I suspect there is something wrong with my environment? You don't need to do 'include HTTParty' inside the Controller. Just remove that

Using rails to consume web services/apis

二次信任 提交于 2019-12-03 18:30:25
问题 I'm new to the rails world and am trying to build a app to simply allow me to search things on Amazon and such sites based on the users input. I've done a little reasearch and it seems the httparty gem is a good place to start? The documents ive found so far though are not the best. They don't really give me a lot of information (where to put the code etc). Are there any existing tutorials out there or code examples that I can either use or take a look at to give me a better idea of how this