Преглед изворни кода

isgd: Update to use new API

Although I can't get this to work. Possibly some kind of TLS negotiation
problem.
Will Storey пре 8 година
родитељ
комит
356b830133
2 измењених фајлова са 11 додато и 9 уклоњено
  1. 1 1
      README.md
  2. 10 8
      isgd.tcl

+ 1 - 1
README.md

@@ -13,7 +13,7 @@ written by others.
 * horgh_autoop.tcl - auto op all users in a channel which is set
   `+horgh_autoop`
 * irb.tcl - unsafe public ruby interpreter
-* isgd.tcl - provide function that shortens a given url using http://is.gd
+* isgd.tcl - a package that provides a function to shorten urls using https://is.gd
 * latoc.tcl - queries yahoo commodity listings for: energy, metals, grains,
   livestock, softs
 * mysqlquote.tcl

+ 10 - 8
isgd.tcl

@@ -6,17 +6,19 @@
 package provide isgd 0.1
 
 package require http
+package require tls
+::http::register https 443 [list ::tls::socket -ssl2 0 -ssl3 0 -tls1 1]
 
-namespace eval isgd {
-	variable url http://is.gd/api.php
+namespace eval ::isgd {
+	variable url https://is.gd/create.php
 }
 
-proc isgd::shorten {url} {
-	set query [http::formatQuery longurl $url]
-	set token [http::geturl ${isgd::url}?${query} -timeout 20000 -method GET]
-	set data [http::data $token]
-	set ncode [http::ncode $token]
-	http::cleanup $token
+proc ::isgd::shorten {url} {
+	set query [::http::formatQuery format simple url $url]
+	set token [::http::geturl ${::isgd::url}?${query} -timeout 20000 -method GET]
+	set data [::http::data $token]
+	set ncode [::http::ncode $token]
+	::http::cleanup $token
 
 	if {$ncode != 200} {
 		error "HTTP error ($ncode): $data"