Skip to content

Instantly share code, notes, and snippets.

View benbonnet's full-sized avatar

Ben benbonnet

View GitHub Profile
#################################################################
# VENUE SEARCH => http://www.lastfm.fr/api/show?service=396 #
# TRACK SEARCH => http://www.lastfm.fr/api/show?service=286 #
# ARTIST SEARCH => http://www.lastfm.fr/api/show?service=272 #
# ALBUM SEARCH => http://www.lastfm.fr/api/show?service=357 #
#################################################################
@keyword = params[:search][:keyword]
keyword = CGI::escape(@keyword)
api = "xxxxx"
def google_login # securite faible
if params[:token]
user = User.find(session[:user])
token = params[:token]
http = Net::HTTP.new('www.google.com', 443)
http.use_ssl = true
path = '/accounts/AuthSubSessionToken'
headers = {'Authorization' => "AuthSubtoken=\"#{token}\""}
resp, data = http.get(path, headers)
@keyword = params[:search][:keyword]
keyword = CGI::escape(@keyword)
api = "xxxxx"
method = "flickr.photos.search"
remote_url = "http://api.flickr.com/services/rest/?method=#{method}&api_key=#{api}&tags=#{keyword}&per_page=20"
@doc = Hpricot.parse(open(remote_url))
render(:update) do |page|
page.replace_html "api_content", :partial => "flickr/search"
end
def photo
@photo_url = CGI::unescape("#{params[:photo_url]}")
id = params[:id]
# affiche la photo sur son format le plus grand dispo dans l'api
# la photo n'est pour le moment pas enregistré
# l'appel est caché
check = Item.find(:first, :conditions => {:item_type_id => 5, :remote_url => @photo_url})
if check.nil?
api = "xxxxxx"
@photoset_id = params[:id]
api_key = "xxxxx"
method = "flickr.photosets.getPhotos"
remote_url = "http://api.flickr.com/services/rest/?method=#{method}&api_key=#{api_key}&photoset_id=#{@photoset_id}"
@doc = Hpricot.parse(open(remote_url))
*******
- @doc.search('photo').collect do |e|
- id = e['id']
require 'net/http'
require 'rexml/document'
http = Net::HTTP.new('docs.google.com', 80)
path = "/feeds/documents/private/full"
headers = {'Authorization' => "AuthSubtoken=\"#{api.token}\""}
resp, data = http.get(path, headers)
@doc = Hpricot.XML(open(data.body))
require 'net/http'
http = Net::HTTP.new('www.google.com', 80)
path = "/m8/feeds/contacts/default/base?max-results=10000"
headers = {'Authorization' => "AuthSubtoken=\"#{api.token}\""}
resp, data = http.get(path, headers)
@doc = Hpricot.XML(open(data.body))
require 'net/http'
require 'rexml/document'
http = Net::HTTP.new('www.google.com', 80)
path = "/calendar/feeds/default/private/full"
headers = {'Authorization' => "AuthSub token=\"#{api.token}\"", "GData-Version" => "2"}
resp, data = http.get(path, headers)
require 'net/http'
require 'rexml/document'
http = Net::HTTP.new('www.google.com', 443)
http.use_ssl = true
path = "/webmasters/tools/feeds/sites/"
headers = {'Authorization' => "AuthSub token=\"#{api.token}\""}
resp, data = http.get(path, headers)
@doc = Hpricot.XML(open(data.body))
@benbonnet
benbonnet / gportfolio_get.rb
Created May 28, 2009 14:20
Google Portfolio
require 'net/http'
require 'rexml/document'
http = Net::HTTP.new('finance.google.com', 80)
path = "/finance/feeds/default/portfolios"
headers = {'Authorization' => "AuthSubtoken=\"#{api.token}\""}
resp, data = http.get(path, headers)
@doc = Hpricot.XML(open(data.body))