<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Blog of Denis Borisenko</title>
	<atom:link href="http://blog.dborisenko.com/en/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.dborisenko.com/en/</link>
	<description>All that interests me</description>
	<lastBuildDate>Wed, 04 Aug 2010 18:05:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Twitter API ActionScript 3.0 library</title>
		<link>http://blog.dborisenko.com/en/2010/02/06/twitter-api-actionscript-3-0-library/</link>
		<comments>http://blog.dborisenko.com/en/2010/02/06/twitter-api-actionscript-3-0-library/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 17:01:08 +0000</pubDate>
		<dc:creator>Denis Borisenko</dc:creator>
				<category><![CDATA[Uncategorized @en]]></category>
		<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://blog.dborisenko.com/?p=300</guid>
		<description><![CDATA[I wrote Twitter API ActionScript 3.0 library for Adobe Flash, Adobe Flex, Adobe AIR. It was tested and used on Adobe AIR. oAuth is used for authentication to the twitter server and is implemented using oAuth ActionScript 3.0 library. Twitter API ActionScript 3.0 library on Google Code.]]></description>
			<content:encoded><![CDATA[<p>I wrote <a href="http://twitter.com/">Twitter</a> <a href="http://apiwiki.twitter.com/">API</a> ActionScript 3.0 library for Adobe Flash, Adobe Flex, Adobe AIR. It was tested and used on Adobe AIR. <a href="http://oauth.net/">oAuth</a> is used for authentication to the twitter server and is implemented using <a href="http://code.google.com/p/oauth-as3/">oAuth ActionScript 3.0 library</a>.</p>
<p><a href="http://code.google.com/p/twitter-actionscript-api/">Twitter API ActionScript 3.0 library</a> on Google Code.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dborisenko.com/en/2010/02/06/twitter-api-actionscript-3-0-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extended UTF-8 in OAuth ActionScript library</title>
		<link>http://blog.dborisenko.com/en/2009/09/05/extended-utf-8-in-oauth-actionscript-library/</link>
		<comments>http://blog.dborisenko.com/en/2009/09/05/extended-utf-8-in-oauth-actionscript-library/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 20:13:35 +0000</pubDate>
		<dc:creator>Denis Borisenko</dc:creator>
				<category><![CDATA[Adobe Flash/Flex/AIR]]></category>
		<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[OAuth]]></category>

		<guid isPermaLink="false">http://blog.dborisenko.com/?p=221</guid>
		<description><![CDATA[The library of Iotashan doesn&#8217;t work correct with Extended UTF-8 characters. If you use this characters (for example, characters of the Russian language) in the parameters and his class URLEncoding you&#8217;ll receive error of invalid signature. In one of the comments of his blog was suggested that the use of class URLEncoding to use the [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://code.google.com/p/oauth-as3/">library</a> of <a href="http://www.iotashan.com/index.php/2008/04/28/oauth-actionscript-library/">Iotashan</a> doesn&#8217;t work correct with Extended UTF-8 characters. If you use this characters (for example, characters of the Russian language) in the parameters and his class <code><a href="http://code.google.com/p/oauth-as3/source/browse/trunk/src/org/iotashan/utils/URLEncoding.as">URLEncoding</a></code> you&#8217;ll receive error of invalid signature.<span style="background-color: #ffffff;"><br />
In one of the <a href="http://www.iotashan.com/index.php/2008/04/28/oauth-actionscript-library/#comment-394">comments</a> of his blog was suggested that the use of class <code>URLEncoding</code> to use the function <code>encodeURIComponent</code>. However, in this case, the same error was received during the use of some special characters (&#8216;!&#8217;, &#8216;*&#8217;, perhaps some others).</span><br />
<span id="more-221"></span></p>
<p>The solution of this error was the implementation of three methods:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> utf8Encode<span style="color: #000000;">&#40;</span>string<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>
<span style="color: #000000;">&#123;</span>
	string = string.<span style="color: #004993;">replace</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight: bold;">/</span>\r\n<span style="color: #000000; font-weight: bold;">/</span>g,<span style="color: #990000;">'<span style="">\n</span>'</span><span style="color: #000000;">&#41;</span>;
	string = string.<span style="color: #004993;">replace</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight: bold;">/</span>\r<span style="color: #000000; font-weight: bold;">/</span>g,<span style="color: #990000;">'<span style="">\n</span>'</span><span style="color: #000000;">&#41;</span>;
&nbsp;
	<span style="color: #6699cc; font-weight: bold;">var</span> utfString<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #990000;">''</span>;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span> ; i <span style="color: #000000; font-weight: bold;">&lt;</span> string.<span style="color: #004993;">length</span> ; i<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #6699cc; font-weight: bold;">var</span> chr<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = string.<span style="color: #004993;">charCodeAt</span><span style="color: #000000;">&#40;</span>i<span style="color: #000000;">&#41;</span>;
		<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>chr <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">128</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			utfString <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #004993;">String</span>.<span style="color: #004993;">fromCharCode</span><span style="color: #000000;">&#40;</span>chr<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>chr <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight:bold;">127</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #000000;">&#40;</span>chr <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">2048</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			utfString <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #004993;">String</span>.<span style="color: #004993;">fromCharCode</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>chr <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight:bold;">6</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000; font-weight:bold;">192</span><span style="color: #000000;">&#41;</span>;
			utfString <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #004993;">String</span>.<span style="color: #004993;">fromCharCode</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>chr <span style="color: #000000; font-weight: bold;">&amp;</span> <span style="color: #000000; font-weight:bold;">63</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000; font-weight:bold;">128</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">else</span>
		<span style="color: #000000;">&#123;</span>
			utfString <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #004993;">String</span>.<span style="color: #004993;">fromCharCode</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>chr <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight:bold;">12</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000; font-weight:bold;">224</span><span style="color: #000000;">&#41;</span>;
			utfString <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #004993;">String</span>.<span style="color: #004993;">fromCharCode</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>chr <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight:bold;">6</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">&amp;</span> <span style="color: #000000; font-weight:bold;">63</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000; font-weight:bold;">128</span><span style="color: #000000;">&#41;</span>;
			utfString <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #004993;">String</span>.<span style="color: #004993;">fromCharCode</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>chr <span style="color: #000000; font-weight: bold;">&amp;</span> <span style="color: #000000; font-weight:bold;">63</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000; font-weight:bold;">128</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">return</span> utfString;
<span style="color: #000000;">&#125;</span>
<span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> urlEncode<span style="color: #000000;">&#40;</span>string<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> urlString<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #990000;">''</span>;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span> ; i <span style="color: #000000; font-weight: bold;">&lt;</span> string.<span style="color: #004993;">length</span> ; i<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #6699cc; font-weight: bold;">var</span> chr<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = string.<span style="color: #004993;">charCodeAt</span><span style="color: #000000;">&#40;</span>i<span style="color: #000000;">&#41;</span>;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>chr <span style="color: #000000; font-weight: bold;">&gt;</span>= <span style="color: #000000; font-weight:bold;">48</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> chr <span style="color: #000000; font-weight: bold;">&lt;</span>= <span style="color: #000000; font-weight:bold;">57</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #009900;">// 09</span>
			<span style="color: #000000;">&#40;</span>chr <span style="color: #000000; font-weight: bold;">&gt;</span>= <span style="color: #000000; font-weight:bold;">65</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> chr <span style="color: #000000; font-weight: bold;">&lt;</span>= <span style="color: #000000; font-weight:bold;">90</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #009900;">// AZ</span>
			<span style="color: #000000;">&#40;</span>chr <span style="color: #000000; font-weight: bold;">&gt;</span>= <span style="color: #000000; font-weight:bold;">97</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> chr <span style="color: #000000; font-weight: bold;">&lt;</span>= <span style="color: #000000; font-weight:bold;">122</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #009900;">// az</span>
			chr == <span style="color: #000000; font-weight:bold;">45</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #009900;">// -</span>
			chr == <span style="color: #000000; font-weight:bold;">95</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #009900;">// _</span>
			chr == <span style="color: #000000; font-weight:bold;">46</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #009900;">// .</span>
			chr == <span style="color: #000000; font-weight:bold;">126</span><span style="color: #000000;">&#41;</span> <span style="color: #009900;">// ~</span>
		<span style="color: #000000;">&#123;</span>
			urlString <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #004993;">String</span>.<span style="color: #004993;">fromCharCode</span><span style="color: #000000;">&#40;</span>chr<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">else</span>
		<span style="color: #000000;">&#123;</span>
			urlString <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #990000;">'%'</span> <span style="color: #000000; font-weight: bold;">+</span> chr.<span style="color: #004993;">toString</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">16</span><span style="color: #000000;">&#41;</span>.<span style="color: #004993;">toUpperCase</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">return</span> urlString;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> encode<span style="color: #000000;">&#40;</span>string<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">return</span> urlEncode<span style="color: #000000;">&#40;</span>utf8Encode<span style="color: #000000;">&#40;</span>string<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Then when you replace all the methods used in the library <code>URLEncoding.encode</code> above a certain method <code>encode</code> the specified error no longer occurs. </p>
<p>Helped to understand what an error <a href="http://www.hueniverse.com/hueniverse/2008/10/beginners-gui-1.html">Beginner&#8217;s Guide to OAuth &#8211; Part IV: Signing Requests</a>, and a script <a href="http://nouncer.com/blog/guide4.js">guide4.js.</a></p>
<p><strong>UPD:</strong><br />
The <a href="http://code.google.com/p/oauth-as3/source/detail?r=13">new version</a> now works correctly with extended characters UTF-8. Thank you <a href="http://www.iotashan.com/">Shannon Hicks</a> for a quick update. And also, thank you for such a cool library. <img src='http://blog.dborisenko.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>UPD:</strong><br />
To view full code of class, please, look at this <a href='http://blog.dborisenko.com/wp-content/uploads/2009/09/URLUtil.as'>file</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dborisenko.com/en/2009/09/05/extended-utf-8-in-oauth-actionscript-library/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
