This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

url shortener

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
NewzNZ
Halfop
Posts: 68
Joined: Thu Mar 05, 2009 5:15 am
Contact:

url shortener

Post by NewzNZ »

Hi there
I had been running a script to use v.gd and is.gd for delivering shortened urls of news stories to a channel...but lately has been returning nothing despite the sites appearing to still be working.
Was wondering if anyone has had experience using these sites in scripts? Currently the only other shortener site I've been able to use sucessfully is tinyurl but would prefer the reduced length of the first 2 mentioned.

Thanks in advance for any help!
User avatar
CrazyCat
Revered One
Posts: 1301
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Can you provide your scripts so we can test and look for an explanation and/or a solution
User avatar
NewzNZ
Halfop
Posts: 68
Joined: Thu Mar 05, 2009 5:15 am
Contact:

Post by NewzNZ »

Thanks & apologies for the spectacularly slow reply:

Code: Select all

set query [::http::geturl http://v.gd/create.php?url=$somelongurltoshorten&format=simple]
set url [lindex [split [::http::data $query] \n] 0]
putserv "PRIVMSG $channel :$url"
Thanks again!
User avatar
CrazyCat
Revered One
Posts: 1301
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

v.gd now uses https, so you need the tls package and modify the script like this:

Code: Select all

::http::register https 443 [list ::tls::socket -autoservername true]
set query [::http::geturl https://v.gd/create.php?url=$somelongurltoshorten&format=simple]
set url [lindex [split [::http::data $query] \n] 0]
::http::cleanup $query
::http::unregister https
putserv "PRIVMSG $channel :$url"
User avatar
NewzNZ
Halfop
Posts: 68
Joined: Thu Mar 05, 2009 5:15 am
Contact:

Post by NewzNZ »

Thanks for this - looks like perhaps my shell provider dosn't have the needed items as it's still returning an empty url...
Thanks anyway.
User avatar
CrazyCat
Revered One
Posts: 1301
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

did you add package require tls after the package require http line in your script ?
User avatar
NewzNZ
Halfop
Posts: 68
Joined: Thu Mar 05, 2009 5:15 am
Contact:

Post by NewzNZ »

added to top of script:

package require http
package require tls

but bot quit with this error when rehashed:

Tcl error in file 'i.conf':
can't find package tls
while executing
"package require tls"
User avatar
NewzNZ
Halfop
Posts: 68
Joined: Thu Mar 05, 2009 5:15 am
Contact:

Post by NewzNZ »

ps not sure if it helps but the script I use for tinyurl is:

Code: Select all

set query [::http::geturl http://tinyurl.com/api-create.php?url=$someurl]
	set url [lindex [split [::http::data $query] \n] 0]
...and it seems to work without the https even though tinyurl is also an https site?
User avatar
CrazyCat
Revered One
Posts: 1301
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Ok, so you upgrade your tcl version, or ask your hoster to upgrade it, as tls is in tcl since version 8.4.

And tinyurl allows the non-https queries when v.gd forces the https usage (tested and verified)
User avatar
NewzNZ
Halfop
Posts: 68
Joined: Thu Mar 05, 2009 5:15 am
Contact:

Post by NewzNZ »

Thanks...will send them a message.
Appreciate the help!
Post Reply