Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6471491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:13:48+00:00 2026-05-25T06:13:48+00:00

I want to send a request via Viralheat’s API in my controller’s update method

  • 0

I want to send a request via Viralheat’s API in my controller’s update method so that when a user hits the submit button, an action is completed and the API call is made. I want to post to http://www.viralheat.com/api/sentiment/review.json?text=i&do&not&like&this&api_key=%5B* your api key *]

This will return some JSON in the format:

{"mood":"negative","prob":0.773171679917001,"text":"i do not like this"}

Is it possible to make that API call simultaneously while executing the controller method and how would I handle the JSON response? Which controller method would I put it in?

Ultimately I’d like to save the response mood to my sentiment column in a BrandUsers table. Submit is in main.html.erb which then uses the update method.

Controller

def update
  @brand = Brand.find(params[:id])
  current_user.tag(@brand, :with => params[:brand][:tag_list], :on => :tags)
  if @brand.update_attributes(params[:brand])
    redirect_to :root, :notice  => "Brand tagged."
  else
    render :action => 'edit'
  end
end

def main
  @brands = Brand.all
  if current_user
    @brand = current_user.brands.not_tagged_by_user(current_user).order("RANDOM()").first
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:13:48+00:00Added an answer on May 25, 2026 at 6:13 am

    With the wrest gem installed, you could do something like

    params[:api_key] = "your key"
    
    url = "http://www.viralheat.com/api/sentiment/review.json"
    
    response = url.to_uri.get(params).deserialize
    

    response would contain the json already turned into a hash. So you can access the mood with

    response[:mood]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want so send every week an update by email. But Im afraid that
I want to send an image to a saas via an http post request.
I'm writing an Android application that I want to be able to send requests
For testing purposes I want send mail to my localhost user account rather than
I need a php script that accepts a URL via a get request and
I need to use a GET request to send JSON to my server via
I want to send an array via $.ajax to a PHP Script. <?php $arrid=array("a","b","c","d","e","f");
I want to send a request to some server just before the phone shuts
I want to send []byte data over http via post on Google App Engine
I have 2 parameters, User and Pass . I want to send them to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.