Solved

How to use keyedlist instead of dictionary in TCL

Posted on 2011-03-25
2
476 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now