Skip to content

Instantly share code, notes, and snippets.

@kayakaya
Created March 9, 2011 13:48
Show Gist options
  • Save kayakaya/862205 to your computer and use it in GitHub Desktop.
Save kayakaya/862205 to your computer and use it in GitHub Desktop.
diff --git a/plugin/flickr.rb b/plugin/flickr.rb
index 9c82f83..dd8ea99 100644
--- a/plugin/flickr.rb
+++ b/plugin/flickr.rb
@@ -18,10 +18,12 @@
# Copyright (c) MATSUOKA Kohei <http://www.machu.jp/>
# Distributed under the GPL
#
-require 'open-uri'
+require 'net/http'
require 'digest/md5'
require 'rexml/document'
+Net::HTTP.version_1_2
+
def flickr(photo_id, size = nil, place = 'flickr')
unless @conf['flickr.apikey'] || @conf['flickr.apikey'].empty?
return '[ERROR] flickr.rb: API Key is not specified.'
@@ -92,7 +94,7 @@ def flickr_open(method, photo_id)
begin
timeout(5) do
open(file, 'w') {|fout|
- req.open.each {|line| fout.puts line }
+ fout.puts req.open
}
end
rescue TimeoutError => e
@@ -168,7 +170,10 @@ module Flickr
end
def open(*param, &block)
- Kernel::open(query, *param, &block)
+ Net::HTTP.start('www.flickr.com') {|http|
+ response = http.get(query)
+ return response.body
+ }
end
def query
@@ -182,13 +187,13 @@ module Flickr
end
def base_url
- 'http://api.flickr.com/services/rest/?'
+ '/services/rest/?'
end
end
class RequestAuth < Request
def base_url
- 'http://www.flickr.com/services/auth/?'
+ '/services/auth/?'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment