I want to read data from an API ean without using any gem. What I want is when the user searches for a particular hotel then my query should return me a data from ean.
How can I go about this thing? and how/where do I add the api key and secret ?
You can perform HTTP requests in Ruby using the Net::HTTP standard library.
Most people prefer to use third party Gems because they offer additional features or cleaner API, compared to Net::HTTP.
However, most of them is based on Net::HTTP itself.
Its a soap API you can use savon to build your own class to access that api. YOu will find a screencast for savon here: http://railscasts.com/episodes/290-soap-with-savon I had a look at the documentation its pretty well documented.
Related
I am trying to use Google's new speech to text api: https://cloud.google.com/speech/docs/rest-tutorial . They currently have python and node.js examples.
Unfortunately, my application is RoR. I was looking through https://github.com/GoogleCloudPlatform/gcloud-ruby , which is a gem that interacts with google cloud services (but not speech). I was hoping that I could use the two together to come out with a working solution, but my knowledge of how to use API's is limited.
Enough background, my questions are:
Does anyone know if Google is going to put out a Ruby version of the speech to text api? If yes, is there a timeline?
If I am impatient, how would I go about using their current API's. By this I mean, is there a good resource for someone to learn how to use generic API's?
The gcloud-ruby gem now supports google-cloud-speech.
To address your other questions, there are no language specific versions of the APIs themselves. They are all HTTP APIs (either REST or gRPC), so they can be used from anything that can make HTTP requests. It can be tricky to use them directly though, because of things like how authentication is handled, which is why client libraries exist for different languages.
If you want to learn more about how to use the REST APIs directly, first take a look at the doc 'Using OAuth 2.0 for Web Server Applications' to find out how to manually authenticate, which has examples for Ruby and raw HTTP/REST.
How can I access the Appery.io (or any future db) that is exposed to the REST API using RoR?
So I have an app i built using Appery.io and I also created a test app using RoR that I would like to use to pull information from the Appery.io db and display it on my RoR app.
I am somewhat familiar with REST and get the idea of what it is doing but I am not to certain on how to connect or make a connection from my RoR app to my Appery.io app. Appery.io has the following documentation for their db api, Appery.io DB API .
I have been looking around and also have seen people mention the following gems for HTTP request:
Weary
HTTParty
RestClient
Would I use one of those? I also read about using Active Resource as a possible solution?
Any help with getting started or a tutorial or article to point me in the right direction would be very helpful.
Thanks!
You won't be establishing an ongoing connection, each request/response will be a single query to your Appery DB. You authenticate those calls using a custom header with API key as defined in the documentation. There's an example using cURL that might be a good place to start playing with the API before you pull it into your RoR app. That example shows you how to get your key, too.
It looks like you can use the predefined APIs, or you can define a custom REST API associated with your Appery app? Instructions for building an API appear to be here.
Once you get the calls working from cURL (or other web request client of your choice), adding the calls to the RoR app should be more straightforward. Any of those gems could probably ease that process: I've only used RestClient personally, but found it very straightforward.
Any of those call methods (cURL, other clients, the gems, etc) will allow you specify your URI, method (e.g. GET or POST), headers, request body (where appropriate), and will allow you to examine your response. Take a look at the gem documentation to see how those map exactly - it will vary slightly from tool to tool.
If you don't have prior experience with calling external APIs, and would like a conceptual explanation, I like this article as a (very short!) beginner's guide.
I am creating a job website where candidate fill his information and admin/team member can modify these detail and after modification i want to send this data to some other application where it get saves .notice that i want to push each single record like in every candidate information page there will be a button for "push to other application"
I am thinking to do this by creating soap services and sending data through soap api,so please help me by assisting how can i create soap api in rails and send data tho other application.
And please assist me the other ways how can i do this.
Thanks!
You can connect to other application database and insert the records. The other application can read the records from its database. It is easier to use database communication than soap.
You should not even think about creating a SOAP service, there are no any good implementations of it in Ruby.
Consider using REST API and ActiveResource instead.
ActiveResource GitHub page
ActiveResource 3.2.17 Docs
There are RailsCasts about ActiveResource, though they are a bit outdated you'll get the idea.
#94 ActiveResource Basics
#95 More on ActiveResource
However if for some reason you decide to create a SOAP service take a look at WashOut and Savon gems.
I have just completed Hartl's book on rails. Following the examples have been helpful and I have been able to build some very basic functionality for my app. However, there is this API I would like to use, and have been granted a key for the API. I have absolutely no idea how to start implementing the API. The other stuff surrounding API's have been helpful, but I literally am stuck on what the very first step should be to begin implementing the API.
I need for a user to be able to sign up and authenticate, then supply data that will be tracked through the external API. I've got the user sign up and authenticate stuff down pat, just need to know what the very first baby step to using this API should be.
The logic behind the answer would be equally helpful.
You can use ActiveResource for your model and point it to the external API. This is useful if your model uses an external data source.
http://api.rubyonrails.org/classes/ActiveResource/Base.html
If the external API you want to use is a well known, there is a good chance that there is already a gem for interaction with that API.
If you only need to send some data to the external API but your model does not use it as its source, you can use an HTTP client like Faraday https://github.com/technoweenie/faraday
I am going to make a very simple web application. I only need the friend list of the current user and then send a message to a selected user with an image/text. I have looked after gems that wraps the detail of extracting data from Facebook and I found some gems, but they all use the old REST API. First of all: is it bad to use the REST API? If not, is "Facebooker" a good gem? If it is bad I found this Which Ruby gems support the Facebook API? but I don't see much of documentation for the Facebooker2. Are there other options?
i'm using koala - works with OAuth authentication and Facebook Graph API. Didn't have any serious problems with it, and it's pretty well documented (with examples) on github
The Ruby Toolbox is a great resource for this kind of question.
In your case, try searching for 'facebook' -- as in https://www.ruby-toolbox.com/search?utf8=%E2%9C%93&q=facebook -- and you'll find that https://github.com/nov/fb_graph is a popular and well-maintained FB gem (at least riight now).
Since Facebook introduced the Open Graph API I've found it's pretty easy to just roll my own wrapper for the REST calls I need using an http client like HTTParty or RestClient. YMMV.