Solved

How to use keyedlist instead of dictionary in TCL

Posted on 2011-03-25
2
485 Views
Last Modified: 2013-11-22
Hello,
I have the following code, but this does not function for me because the version I have does not support dictionaries. So instead I must use keyedlist.
Can you please assist in conversion to keyedlist instead?

The code is simply declaring declaring and appending values to dict = oauth_raw
proc oauth::query_call {url consumer_key consumer_secret method params {sign_params {}} {token_secret {}}} {
	set oauth_raw [dict create oauth_nonce [oauth::nonce]]
	dict append oauth_raw oauth_signature_method HMAC-SHA1
	dict append oauth_raw oauth_timestamp [clock seconds]
	dict append oauth_raw oauth_consumer_key $consumer_key
	dict append oauth_raw oauth_version 1.0

	# variable number of params
	foreach param $params {
		dict append oauth_raw {*}$param
	}

	# second oauth_raw holds data to be signed but not placed in header
	set oauth_raw_sign $oauth_raw
	foreach key [dict keys $sign_params] {
		dict append oauth_raw_sign $key [dict get $sign_params $key]
	}

	set signature [oauth::signature $url $consumer_secret $method $oauth_raw_sign $token_secret]
	dict append oauth_raw oauth_signature $signature

	set oauth_header [oauth::oauth_header $oauth_raw]
	set oauth_query [oauth::uri_escape $sign_params]

	return [oauth::query $url $method $oauth_header $oauth_query]
}

Open in new window

0
Comment
Question by:badtz7229
2 Comments
 
LVL 15

Accepted Solution

by:
mish33 earned 500 total points
ID: 35281987
Something like below. You also need modify other oauth:: procs to accept array insted of dict as params.
proc oauth::query_call {url consumer_key consumer_secret method params {sign_params {}} {token_secret {}}} {
	array set oauth_nonce [oauth::nonce]
	array set oauth_raw {
	  oauth_signature_method HMAC-SHA1
	  oauth_timestamp [clock seconds]
	  oauth_consumer_key $consumer_key
	  oauth_version 1.0 }

	# variable number of params
	foreach param $params {
		set oauth_raw($param) ""
	}

	# second oauth_raw holds data to be signed but not placed in header
	set oauth_raw_sign $oauth_raw
	foreach key [array names sign_params] {
		set oauth_raw_sign($key) $sign_params($key)
	}

	set signature [oauth::signature $url $consumer_secret $method $oauth_raw_sign $token_secret]
	set oauth_raw(oauth_signature) $signature

	set oauth_header [oauth::oauth_header $oauth_raw]
	set oauth_query [oauth::uri_escape $sign_params]

	return [oauth::query $url $method $oauth_header $oauth_query]
}

Open in new window

0
 

Author Closing Comment

by:badtz7229
ID: 35401997
i need to make some chagnes
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question