Posted to tcl by aspect at Fri Feb 12 05:41:45 GMT 2016view raw

  1. package require http
  2. package require tls
  3.  
  4. ::http::register https 443 tls:socket
  5.  
  6. proc tls:socket args {
  7. set opts [lrange $args 0 end-2]
  8. set host [lindex $args end-1]
  9. set port [lindex $args end]
  10. ::tls::socket -ssl3 false -ssl2 false -tls1 true -servername $host {*}$opts $host $port
  11. }
  12.  
  13. set json {{"authToken":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZGVudGl0eUlEIjoidXMtZWFzdC0xOmM0MDE3M2IxLTljODMtNGVkYy1hZWZlLTM1YTY5MzU2ZjM5NSIsInN5c3RlbUlEIjoiMDA6MUY6Qjg6MTI6MDU6MzEiLCJ0b2tlbkV4cGlyZXMiOjE0NTU4NDM0ODkxMDV9.20J4BOAx2a7Jdw_gA1MNhal36b7Ig02w2hvcdKLsUjY","localTimestamp":1455253722878,"message":"Hello From URC","category":"Hello, Dash","type":"success","from":"System Monitor"}}
  14.  
  15. try {
  16. set token [::http::geturl "https://napier.digitalsmarties.com/v1/system/log" \
  17. -method POST \
  18. -query $json
  19. ]
  20.  
  21. } on error {result options} {
  22. puts "\n\nError!\n---\n$result\n$options\n----\n\n"
  23. }
  24.  
  25. puts [http::data $token]
  26.