Using Google Search REST API in Ruby
The gem googleajax
is there for that:
require 'googleajax'
GoogleAjax.referer = "your_domain_name_here.com"
GoogleAjax::Search.web("Hello world")[:results][0...3]
Retrieving JSON information from Google Custom Search API using ruby
Net::HTTP uses http without SSL (https) by default. You can see the instructions here:
http://www.rubyinside.com/nethttp-cheat-sheet-2940.html under "SSL/HTTPS request"
require 'uri'
require 'net/https'
params = "key=#{key}&cx=#{cx}&q=#{query}&alt=#{alt}"
uri = URI.parse("https://www.googleapis.com/customsearch/v1?#{params}")
http= Net::HTTP.new(uri.host,uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
r=http.request(Net::HTTP::Get.new(uri.request_uri))
temp_file = 'testfile.html'
File.open(temp_file, 'w') { |f| f.write(r.body) }
`firefox #{temp_file}`
Rails Drive Rest Api | Sharing file using google api client gem
If I pass a permission object like the documentation says, doesn't works, so the correct form, and the only who works for me is:
user_permission = {type: "user", role: "writer", email_address: "some@gmail.com"}
@drive.create_permission(current_user.fileId, user_permission, send_notification_email: false, fields: 'id', &callback)
How to retrieve top 10 Google search results from a keyword through an API in Ruby?
You're not very explicit in your question about the trade offs you're willing to make, But you might want to think about this more:
I think the Google Custom Search might be an option but the daily limit of 100 queries is restricting. I would prefer to not scrape Google as it's a violation of their terms.
I've used google custom search, and it is very easy but the limit is in place. If you are concerned about not violating Google's TOS, this is the only way to go. You need to decide if you're willing to violate the TOS, and if not you should just use the google custom search.
Google Earth Engine REST API Authentication from Ruby fails
I got the same issue in the past.
You need to be accepted/enrolled first by the Google EarthEngine team in order to access the API.
Signup for Earth Engine. Once you have been accepted, you will receive an email with additional information.To signup, follow instructions from the official Google docs here.
It took 1 day in my case and I could then call the API smoothly.
EDIT: The HTTP 401 response you are getting indicates invalid authentication credentials. In my case, the app connects using a Service Account. I followed instructions here and my app could connect smoothly to the Earth Engine. hope it helps
how to send message using Gmail API with Ruby Google API Client?
I think
@gmail.users.messages.send(:get) is equal to @gmail.users.messages.get
because ".send" is ruby methodso now this method is working with
@gmail.users.messages.to_h['gmail.users.messages.send']
example:msg = Mail.new
msg.date = Time.now
msg.subject = options[:subject]
msg.body = Text.new(options[:message])
msg.from = {@_user.email => @_user.full_name}
msg.to = {
options[:to] => options[:to_name]
}
@email = @google_api_client.execute(
api_method: @gmail.users.messages.to_h['gmail.users.messages.send'],
body_object: {
raw: Base64.urlsafe_encode64(msg.to_s)
},
parameters: {
userId: 'me',
}
)
Thanks.
Related Topics
Rails - Understanding Application.Js and Application.CSS
In Ruby, How to Be Warned of Duplicate Keys in Hashes When Loading a Yaml Document
Automating Ssh to Windows with Ruby
Segmentation Fault with Ruby 1.8.7
What Is - Gets Is a Directory - Error Message
Should I Move My Custom Methods to Model from Controller
Streaming CSV Download from Rails 3.2 App
Ruby on Rails Tutorial Section 3.2 Rspec Testing Error
Rails 3.1 Has_One Nested Resource: Routing Not Generating "All" Paths
Gitlab Configuration Issues:: Nginx Unicorn Port Conflict
Puzzled Over Palindromic Product Problem
Permission Error When Trying to Install Rails (Osx)
Can't Log into Active Admin. Any Way to Create an Admin User
How to Handle 404 Errors with Ruby Http::Net
How to Make Http Delete Request in My Ruby Code Using Net::Http