auto_tagging 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/auto_tagging/delicious.rb +41 -8
- data/lib/auto_tagging/version.rb +1 -1
- metadata +1 -1
@@ -8,17 +8,19 @@ module AutoTagging
|
|
8
8
|
PASSWORD = 'notsecure'
|
9
9
|
|
10
10
|
API_HOST = 'api.del.icio.us'
|
11
|
+
API_PAGE = '/v1/posts/suggest'
|
11
12
|
|
12
13
|
def get_tags(opts)
|
13
14
|
AutoTagging::SearchParam.url_search?(opts) ? api_request(url(opts)) : []
|
14
15
|
end
|
15
16
|
|
17
|
+
private
|
18
|
+
|
16
19
|
def api_request(url)
|
17
20
|
wait_for_next_valid_request
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
req = Net::HTTP::Get.new("/v1/posts/suggest?url=#{url}", {"User-Agent" => "auto_tagging ruby gem"})
|
21
|
+
|
22
|
+
prepared_http.start do |http|
|
23
|
+
req = Net::HTTP::Get.new(api_request_url(url), user_agent)
|
22
24
|
req.basic_auth(USERNAME, PASSWORD)
|
23
25
|
parse_response(http.request(req))
|
24
26
|
end
|
@@ -26,10 +28,23 @@ module AutoTagging
|
|
26
28
|
[]
|
27
29
|
end
|
28
30
|
|
29
|
-
def
|
30
|
-
|
31
|
+
def prepared_http
|
32
|
+
http = Net::HTTP.new(API_HOST, 443)
|
33
|
+
http.use_ssl = true
|
34
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
35
|
+
http
|
36
|
+
end
|
37
|
+
|
38
|
+
def api_request_url(url)
|
39
|
+
"#{API_PAGE}?url=#{url}"
|
40
|
+
end
|
31
41
|
|
32
|
-
|
42
|
+
def user_agent
|
43
|
+
{"User-Agent" => "auto_tagging ruby gem"}
|
44
|
+
end
|
45
|
+
|
46
|
+
def parse_response(response)
|
47
|
+
REXML::Document.new(response.body).root.elements.map { |e| e.attributes['tag'] }
|
33
48
|
rescue
|
34
49
|
[]
|
35
50
|
end
|
@@ -42,4 +57,22 @@ module AutoTagging
|
|
42
57
|
"#{URI.encode(AutoTagging::SearchParam.to_valid_url(opts[:url]))}"
|
43
58
|
end
|
44
59
|
end
|
45
|
-
end
|
60
|
+
end
|
61
|
+
|
62
|
+
#ssl certificate ( Chung chi ssl ) was created uniquely for each website
|
63
|
+
#steps
|
64
|
+
#browser request server for ssl certificate
|
65
|
+
#server send back its ssl certificate
|
66
|
+
#browser then verify for the validity of certificate by sending this certificate to GLobalSign or Verisign
|
67
|
+
#browser then send back digital number to encode and decode
|
68
|
+
|
69
|
+
|
70
|
+
#another steps
|
71
|
+
#browser make request to a secure url (https)
|
72
|
+
#web server sends its public key with its certificate
|
73
|
+
#browser then check for its validity (issued by a trusted party, still valid, related to site contacted)
|
74
|
+
#browser then use public key to encrypt a random symmetric encryption key and sends it to the server
|
75
|
+
#The web server decrypts the symmetric encryption key using its private key and uses the symmetric key to decrypt the URL and http data.
|
76
|
+
|
77
|
+
#public key => send out to everybody , let them encrypt some data with this public key and send back the encrypted data
|
78
|
+
#private key => use to decrypt the encrypted data which is encrypted by the sent out public key
|
data/lib/auto_tagging/version.rb
CHANGED