Solved

How to use keyedlist instead of dictionary in TCL

Posted on 2011-03-25
2
494 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…

717 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