Monday, November 08, 2010 at 12:01 AM.


on getAccessToken (endpoint, consumerkey, consumersecret, token, tokensecret, verifier=nil, adrtoken, adrtokensecret) {
		<<1/1/10; 11:31:09 AM by DW
			<<Add optional parameter, verifier, if non-nil, we send it as the oauth_verifier param, per the spec on the Twitter API wiki.
		<<3/6/09; 8:53:19 AM by DW
			<<Comment debugging code.
		<<2/12/09; 12:16:28 PM by DW
	local (params);
	new (tabletype, @params);
	params.oauth_version = "1.0";
	params.oauth_nonce = OAuth.getNonce ();
	params.oauth_timestamp = OAuth.getTimeStamp ();
	params.oauth_consumer_key = consumerKey;
	params.oauth_signature_method = "HMAC-SHA1";
	params.oauth_token = token;
	if verifier != nil { //1/1/10 by DW
		params.oauth_verifier = verifier};
	params.oauth_signature = OAuth.getSignature (@params, endpoint, consumersecret, tokenSecret);
	local (s = OAuth.httpClient (endpoint, @params));
	<<wp.newtextobject (s, @scratchpad.accesstokenresult); edit (@scratchpad.accesstokenresult)
	bundle { //parse the resulting string
		adrtoken^ = string.nthfield (string.nthfield (s, "&", 1), "=", 2);
		adrtokensecret^ = string.nthfield (string.nthfield (s, "&", 2), "=", 2)}}
<<bundle //test code
	<<local (endpoint = "")
	<<local (consumerkey = "key", consumersecret = "secret")
	<<getAccessToken (endpoint, consumerkey, consumersecret, scratchpad.token, scratchpad.tokensecret, @scratchpad.accesstoken, @scratchpad.accesstokensecret)

This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.