Skip to content

Commit

Permalink
Doesnt crash anymore if no internet
Browse files Browse the repository at this point in the history
  • Loading branch information
Gael committed Nov 18, 2011
1 parent 5219fb2 commit e6a4ed7
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/viadeo/api/query_methods.rb
Expand Up @@ -17,13 +17,16 @@ def simple_query(access_token, path, args)
url = "#{DEFAULT_OAUTH_OPTIONS[:api_base]}#{path}?access_token=#{access_token}"
args.each {|key, value| url += "&#{key}=#{CGI.escape(value.to_s)}"}
uri = URI.parse(url)
(1..3).each do
connection = Net::HTTP.new(uri.host, 443)
connection.use_ssl = true
connection.verify_mode = OpenSSL::SSL::VERIFY_NONE
resp = connection.request_get(uri.path + '?' + uri.query)

return Mash.from_json resp.body if resp.code == '200'
begin
(1..3).each do
connection = Net::HTTP.new(uri.host, 443)
connection.use_ssl = true
connection.verify_mode = OpenSSL::SSL::VERIFY_NONE
resp = connection.request_get(uri.path + '?' + uri.query)
return Mash.from_json resp.body if resp.code == '200'
end
rescue
puts "Error: #{$!}"
end
return nil
end
Expand Down

0 comments on commit e6a4ed7

Please sign in to comment.