httparty

Sending a post query sent via HTTParty

狂风中的少年 提交于 2019-12-12 09:47:47
问题 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

Rails HTTParty Getting Timeout::Error

一曲冷凌霜 提交于 2019-12-12 09:24:33
问题 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 回答1: If I understand correctly

Can someone provide an example for how to post XML using HTTParty and Ruby on Rails?

好久不见. 提交于 2019-12-12 08:45:28
问题 I need to post some xml to a webservice and I'm trying to use HTTParty. Can someone provide an example as to how I go about doing so? Here is the format of the XML I need to post: <Candidate xmlns="com.mysite/2010/10/10" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <FirstName></FirstName> <LastName></LastName> <Email></Email> <Gender></Gender> </Candidate> Here is my class so far: require 'httparty' class Webservice include HTTParty format :xml base_uri 'mysite.com' default_params

HTTParty parsing JSON in Rails

*爱你&永不变心* 提交于 2019-12-12 05:28:18
问题 I have a URL that displays JSON holding info for 400 YMCA locations. My goal is to be able to pull latitude and longitude for each location in order to display the points on a map. I was playing around with HTTParty and just wanted to start by displaying only the latitude and longitude in the view. Here is my controller: require 'rubygems' require 'httparty' class HomesController < ApplicationController include HTTParty def index uri = HTTParty.get"http://www.livestrong.org/we-can-help/ymca

Redirect user to external url with post method and params

时光毁灭记忆、已成空白 提交于 2019-12-11 20:16:15
问题 How do i redirect user to external url via post method? I know redirect_to works only for get requests. How do i achieve this? 回答1: You cannot redirect a user to a POST method. You can present a user with a link that the Rails JS will turn into a form/POST: = link_to "Do it!", "http://other.site/path", method: :post ...or a form that triggers a POST to another site (note that I've included an extra param in this) eg. = form_tag "http://other.site/path", method: :post do = hidden_field_tag

Rails: Post JSON to API Using Rails and HTTParty Not Working

随声附和 提交于 2019-12-11 17:35:53
问题 I am pretty new to API in Rails, although I have gotten some assistance already about how to structure my HTTParty Post Request, but the payload (data) that I am sending does not impact on the database of my API All I want is to create a record on the database of the API through a POST request from my application. That is to create a record on both databases (my database and the on the database of the API through a POST request from my application) whenever I create a book. For the app that

Net HTTP unescapes characters?

折月煮酒 提交于 2019-12-11 08:45:58
问题 Does Ruby Net HTTP unescape characters (for example 龅 to 龅 )? I send a request using HTTParty with 龅 but the request parameters on the request server show 龅 instead. 回答1: Net::HTTP doesn't do any conversion or decoding. It's just a pipe to move data. If you are seeing converted characters on the server side then something there is changing them before you can see them. This shows what Net::HTTP is sending. In test.rb: #!/usr/bin/env ruby require 'ap' require 'sinatra' post '/' do t = %w[text

Strange Timeout::Error with render_to_string and HTTParty in Controller Action

给你一囗甜甜゛ 提交于 2019-12-10 17:49:39
问题 Within my controller action i am using render_to_string with a jbuilder template to render an object for a http post action to an API, the results of this API-Call is what should be rendered by the controller. But i get a strange timeout then i call HTTParty after i rendered the model via render_to_string. Log: [23:43:52.262] [18033] [info] Rendered admin/companies/companies.json.jbuilder (42.8ms) ... nothing happens here (60s timeout) [23:44:52.314] [18033] [info] Completed 500 Internal

Why is #{} not adding the value to the string?

烂漫一生 提交于 2019-12-10 12:02:01
问题 Using httparty I'm making a GET request to: 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 Code 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

How to parse og meta tags using httparty for rails 3

有些话、适合烂在心里 提交于 2019-12-08 05:33:49
问题 I am trying to parse og meta tags using the HTTParty gem using this code: link = http://www.usatoday.com/story/gameon/2013/01/08/nfl-jets-tony-sparano-fired/1817037/ # link = http://news.yahoo.com/chicago-lottery-winners-death-ruled-homicide-181627271.html resp = HTTParty.get(link) ret_body = resp.body # title og_title = ret_body.match(/\<[Mm][Ee][Tt][Aa] property\=\"og:title\"\ content\=\"(.*?)\"\/\>/) og_title = og_title[1].to_s The problem is that it worked on some sites (yahoo!) but not