napa182 commented on a Page, 2 in 1 - Tinyurl and !d (google define) sockets  -  Feb 09, 2011

here is a fast mock up of a POST socket for the tinyurl
it is best if you are going to use a regex not to use a greedy one^^

alias turltest {
  if ($sock(turl)) sockclose turl
  sockopen turl tinyurl.com 80 
  sockmark turl $$1 $replace($2-,$chr(32),+)
}
on *:sockopen:turl:{ 
  var %turl $+(&url=,$gettok($sock(turl).mark,1,32),&submit=Make+TinyURL!$&
    &alias=,$iif($gettok($sock(turl).mark,2,32),$v1,"")),$&
    %turl2 = sockwrite -n turl
  %turl2 POST /create.php?source=indexpage HTTP/1.0 
  %turl2 Host: $sock(turl).addr 
  %turl2 Content-Type: application/x-www-form-urlencoded 
  %turl2 Content-Length: $len(%turl) 
  %turl2 $+($crlf,%turl)
}
on *:sockread:turl: { 
  var %turl | sockread %turl
  if ($regex(%turl,/<blockquote.+>(.+?)<\/b>/)) { 
    echo -a $regml(1)
    sockclose turl
  }
}

But it would be better to use tinyurls api this is from them not me...

DON'T SCREEN-SCRAPE, PLEASE CONTACT US TO FIND OUT HOW TO USE OUR API

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.