<?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>Web company in the heart of Europe: Prague. &#187; nokia.ajax</title>
	<atom:link href="http://talkweb.eu/t/nokia-ajax/feed" rel="self" type="application/rss+xml" />
	<link>http://talkweb.eu</link>
	<description>We talk web</description>
	<lastBuildDate>Wed, 09 May 2012 07:49:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>WRT: How to post to your WordPress using Ajax (+code)</title>
		<link>http://talkweb.eu/openweb/299</link>
		<comments>http://talkweb.eu/openweb/299#comments</comments>
		<pubDate>Thu, 01 Jul 2010 08:28:39 +0000</pubDate>
		<dc:creator>Bogo</dc:creator>
				<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[Open Technologies]]></category>
		<category><![CDATA[nokia.ajax]]></category>
		<category><![CDATA[symbian]]></category>
		<category><![CDATA[wgz]]></category>
		<category><![CDATA[wordpress. metablog]]></category>

		<guid isPermaLink="false">http://talkweb.eu/?p=299</guid>
		<description><![CDATA[I just finished my &#8220;share2&#8243; WRT (Web Runtime Toolkit) widget. It allows me to post quick messages to my WordpPress blog or to any blog that uses MetaWeblog API. Here are some key parts from the script: Ajax function that sends the requests and gets the result function ajExec&#40;url, param, callback, isXML&#41; &#123; var req [...]]]></description>
			<content:encoded><![CDATA[<p>I just finished my &#8220;share2&#8243; WRT (Web Runtime Toolkit) widget. It allows me to post quick messages to my WordpPress blog or to any blog that uses MetaWeblog API.</p>
<p>Here are some key parts from the script:</p>
<h2>Ajax function that sends the requests and gets the result</h2>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> ajExec<span style="color: #009900;">&#40;</span>url<span style="color: #339933;">,</span> param<span style="color: #339933;">,</span> callback<span style="color: #339933;">,</span> isXML<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> req <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> XMLHttpRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    req.<span style="color: #660066;">onreadystatechange</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>req.<span style="color: #660066;">readyState</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">4</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> req.<span style="color: #000066;">status</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">200</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>isXML <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> req.<span style="color: #660066;">responseText</span> <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
                callback<span style="color: #009900;">&#40;</span>req.<span style="color: #660066;">responseText</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>isXML <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> req.<span style="color: #660066;">responseXML</span> <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
                callback<span style="color: #009900;">&#40;</span>req.<span style="color: #660066;">responseXML</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">else</span>
                callback<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>req.<span style="color: #660066;">readyState</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">4</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> req.<span style="color: #000066;">status</span> <span style="color: #339933;">!=</span> <span style="color: #CC0000;">200</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
            <span style="color: #003366; font-weight: bold;">var</span> err <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;Error: &quot;</span><span style="color: #339933;">+</span>req.<span style="color: #000066;">status</span><span style="color: #339933;">;</span>
            <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>err<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            callback<span style="color: #009900;">&#40;</span>err<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
        req.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;POST&quot;</span><span style="color: #339933;">,</span> url<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        req.<span style="color: #660066;">setRequestHeader</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Content-type&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;application/x-www-form-urlencoded&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        req.<span style="color: #660066;">send</span><span style="color: #009900;">&#40;</span>param<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<h2>Let&#8217;s click on Publish button</h2>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> sendButtonClicked<span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     saved_username <span style="color: #339933;">=</span> widget.<span style="color: #660066;">preferenceForKey</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;username&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	 saved_pass <span style="color: #339933;">=</span> widget.<span style="color: #660066;">preferenceForKey</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;pass_s&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	 saved_tags <span style="color: #339933;">=</span> widget.<span style="color: #660066;">preferenceForKey</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;tag&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	 saved_server <span style="color: #339933;">=</span> widget.<span style="color: #660066;">preferenceForKey</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;server&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	 pub <span style="color: #339933;">=</span> blogField.<span style="color: #660066;">getText</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	ajExec<span style="color: #009900;">&#40;</span>saved_server<span style="color: #339933;">,</span><span style="color: #3366CC;">'&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;methodCall&gt;&lt;methodName&gt;metaWeblog.newPost&lt;/methodName&gt;&lt;params&gt;&lt;param&gt;&lt;value&gt;&lt;string&gt;MyBlog&lt;/string&gt;&lt;/value&gt;&lt;/param&gt;&lt;param&gt;&lt;value&gt;&lt;string&gt;'</span><span style="color: #339933;">+</span>saved_username<span style="color: #339933;">+</span><span style="color: #3366CC;">'&lt;/string&gt;&lt;/value&gt;&lt;/param&gt;&lt;param&gt;&lt;value&gt;&lt;string&gt;'</span><span style="color: #339933;">+</span>saved_pass<span style="color: #339933;">+</span><span style="color: #3366CC;">'&lt;/string&gt;&lt;/value&gt;&lt;/param&gt;&lt;value&gt;&lt;struct&gt;&lt;member&gt;&lt;param&gt;&lt;name&gt;title&lt;/name&gt;&lt;value&gt;&lt;string&gt;This is a post&lt;/string&gt;&lt;/value&gt;&lt;/param&gt;&lt;/member&gt;&lt;member&gt;&lt;param&gt;&lt;name&gt;description&lt;/name&gt;&lt;value&gt;&lt;string&gt;'</span><span style="color: #339933;">+</span>pub<span style="color: #339933;">+</span><span style="color: #3366CC;">'&lt;/string&gt;&lt;/value&gt;&lt;/param&gt;&lt;/member&gt;&lt;/struct&gt;&lt;/value&gt;&lt;param&gt;&lt;value&gt;&lt;boolean&gt;1&lt;/boolean&gt;&lt;/value&gt;&lt;/param&gt;&lt;/params&gt;&lt;/methodCall&gt;'</span><span style="color: #339933;">,</span>showAnswer<span style="color: #339933;">,</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The milestone was to find correct XML structure for the query, because the examples from WordPress website and other websites are all wrong. <strong>Please see the XML and it&#8217;s structure</strong></p>
<h2>Download this script</h2>
<p>You can download the application and see how works <a href="http://talkweb.eu/wp-content/uploads/2010/07/share21.zip">from here.</a>.</p>
<h2>Run it</h2>
<p>The logo:<br />
<img src="http://talkweb.eu/wp-content/uploads/2010/07/share2-1.png" alt="" title="share2-1" width="375" height="188" class="alignnone size-full wp-image-319" /></p>
<p>The Settings screen:<br />
<img src="http://talkweb.eu/wp-content/uploads/2010/07/share2-2.png" alt="" title="share2-2" width="396" height="237" class="alignnone size-full wp-image-320" /></p>
<p>HOW?:<br />
If you want to run it into your Symbian device &#8211; <strong>rename it</strong> to share2.wgz and upload it to your device. The Symbian will do the rest. Tested on Nokia N95.</p>
]]></content:encoded>
			<wfw:commentRss>http://talkweb.eu/openweb/299/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

