<?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>effective life plus &#187; wp7</title>
	<atom:link href="http://www.binzywu.com/tag/wp7/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.binzywu.com</link>
	<description>Binzy&#039;s blog</description>
	<lastBuildDate>Sun, 23 Oct 2011 21:43:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Windows Phone 7, Hammock, OAuth and Sina Weibo&#8217;s API</title>
		<link>http://www.binzywu.com/2011/02/windows-phone-7-hammock-oauth-and-sina-weibos-api/</link>
		<comments>http://www.binzywu.com/2011/02/windows-phone-7-hammock-oauth-and-sina-weibos-api/#comments</comments>
		<pubDate>Thu, 17 Feb 2011 21:47:42 +0000</pubDate>
		<dc:creator>binzywu</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[Hammock]]></category>
		<category><![CDATA[OAuth]]></category>
		<category><![CDATA[Sina]]></category>
		<category><![CDATA[Weibo]]></category>
		<category><![CDATA[windows phone 7]]></category>
		<category><![CDATA[wp7]]></category>
		<category><![CDATA[客户端]]></category>
		<category><![CDATA[微博]]></category>
		<category><![CDATA[新浪]]></category>

		<guid isPermaLink="false">http://www.binzywu.com/?p=145</guid>
		<description><![CDATA[OK, I am developing a windows phone 7 app for Sina Weibo. I just simply don&#8217;t like the basic authorisation&#8230; And OAuth is much better since once you get the access token, you can use it all the time rather than always passing the username and password around. though there are already two Sina Weibo [...]]]></description>
			<content:encoded><![CDATA[<p>OK, I am developing a windows phone 7 app for Sina Weibo. I just simply don&#8217;t like the basic authorisation&#8230; And OAuth is much better since once you get the access token, you can use it all the time rather than always passing the username and password around. though there are already two Sina Weibo client apps (1 free and 1 is asking for $0.99) in marketplace, my friend Remy and I still want to develop a new app which will be free and open source.</p>
<p><span id="more-145"></span></p>
<p>We restarted (or I can say started&#8230;) the development work from this Monday and things are in good progress. In the meantime, I would like to share what we&#8217;ve experienced during development and I hope this can help you if you are thinking to develop your own client on Windows Phone 7 or Silverlight for Sina Weibo. So this first entry is about getting OAuth access token for Sina Weibo via Hammock. Hammock is a great lib for you to consume and wrap RESTful services and it supports OAuth and XAuth.</p>
<p><strong>Step 1 register your app.</strong><br />
Sure, you need to apply/register an application on <a title="Sina Weibo API" href="http://open.t.sina.com.cn/" target="_blank">http://open.t.sina.com.cn/</a>. You will then get your app key and secret (which is actually consumer key and secret).</p>
<p><strong>Step 2 authentication.</strong><br />
OAuth is quite simple and straightforward. In summary, you need to pass your consumer key and secret to get the request token, like this,<br />
<pre><pre>void OAuthTest()
{
    RestClient c = new RestClient()
    {
        Authority = &quot;http://api.t.sina.com.cn/&quot;,
        HasElevatedPermissions = true,
        Credentials = new OAuthCredentials()
        {
            ConsumerKey = &quot;your appkey&quot;,
            ConsumerSecret = &quot;your appsecret&quot;,
            SignatureMethod = OAuthSignatureMethod.HmacSha1,
            ParameterHandling = 
OAuthParameterHandling.HttpAuthorizationHeader,
            Version = &quot;1.0&quot;
        }
    };

    RestRequest r = new RestRequest()
    {
        Path = &quot;oauth/request_token&quot;,

    };

    c.BeginRequest(r, new RestCallback(Callback));

}

void Callback(RestRequest request, RestResponse response, 
object userState)
{
    Regex r = 
new Regex(&quot;oauth_token=([^&amp;amp;.]*)&amp;amp;oauth_token_secret=([^&amp;amp;.]*)&quot;);
    var match = r.Match(response.Content);
    token = match.Groups[1].Value;
    tokensecret = match.Groups[2].Value;
}</pre></pre><br />
once you get the request token and tokensecret, you can pass them along with consumer key for the authorization. Then Sina Weibo API will ask for username and password. But for client app like this, you may want user provide the info at your app and you take care the whole interaction in app. So you could generate a dynamic callback page. Beyond, the Sina Weibo API supports directly xml callback to return the xml which contains the oauth_verifier.<br />
<pre><pre>RestClient c = new RestClient()
{
    Authority = &quot;http://api.t.sina.com.cn/&quot;,
};

RestRequest req = new RestRequest()
{
    Path = string.Format(&quot;oauth/authorize?{0}&amp;amp;oauth_callback=xml
&amp;amp;userId={1}&amp;amp;passwd={2}&quot;, response.Content, &quot;user&quot;, &quot;password&quot;)
};

c.BeginRequest(req, new RestCallback(Callback2));        

void Callback2(RestRequest request, RestResponse response,
 object userState)
{
&nbsp;&nbsp;&nbsp;&nbsp;Regex r = new Regex(&quot;&amp;lt;oauth_token&amp;gt;(.*?)&amp;lt;/oauth_token&amp;gt;
&amp;lt;oauth_verifier&amp;gt;(.*?)&amp;lt;/oauth_verifier&amp;gt;&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;var match = r.Match(response.Content);
}</pre></pre><br />
then you are ready to ask for the access token,<br />
<pre><pre>RestClient c = new RestClient()
{
    Authority = &quot;http://api.t.sina.com.cn/&quot;,
    HasElevatedPermissions = true,
    Credentials = new OAuthCredentials()
    {
        ConsumerKey = &quot;your appkey&quot;,
        ConsumerSecret = &quot;your appsecret&quot;,
        Token = &quot;request token&quot;,
        TokenSecret = &quot;request tokensecret&quot;,
        Verifier = &quot;your oauth verifier from last step&quot;,
        SignatureMethod = OAuthSignatureMethod.HmacSha1,
        ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,
        Type = OAuthType.AccessToken,
        Version = &quot;1.0&quot;
    }
};

RestRequest r2 = new RestRequest()
{
    Path = &quot;oauth/access_token&quot;,

};

c.BeginRequest(r2, new RestCallback(Callback3));

public void Callback3(RestRequest request, RestResponse response, 
object userState)
{
    // you will get format like this and that&#039;s your access
 token: oauth_token=token&amp;amp;oauth_token_secret=secret&amp;amp;user_id=id
    var s = response.Content;
}</pre></pre><br />
<strong>Step 3 make an update to your statuses!</strong><br />
As mentioned before once you&#8217;ve got the access token, the token can be used until the user revokes the authentication. The following things will be very simple. like if you want to post an update from your app, you just need some very familiar codes.<br />
<pre><pre>        private void Test()
        {
            RestClient c = new RestClient()
            {
                Authority = &quot;http://api.t.sina.com.cn/&quot;,
                HasElevatedPermissions = true,
                Credentials = new OAuthCredentials()
                {
                    ConsumerKey = &quot;your appkey&quot;,
                    ConsumerSecret = &quot;your appsecret&quot;,
                    Token = &quot;your access token&quot;,
                    TokenSecret = &quot;your access tokensecret&quot;,
                    SignatureMethod = OAuthSignatureMethod.HmacSha1,
                    ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,
                    Type = OAuthType.ProtectedResource,
                    Version = &quot;1.0&quot;
                }
            };

            RestRequest r2 = new RestRequest()
            {
                Path = &quot;statuses/update.xml&quot;
            };

            r2.AddParameter(&quot;status&quot;, &quot;hello world&quot;);
            r2.Method = WebMethod.Post;
            c.BeginRequest(r2, new RestCallback(Callback));

        }

        void Callback(RestRequest request, RestResponse response,
 object userState)
        {
            // check wheather post is successful
        }</pre></pre><br />
Enjoy.</p>
<p>references:<br />
OAuth:<a href=" http://oauth.net" target="_blank"> http://oauth.net</a><br />
Sina Weibo API: <a href="http://open.t.sina.com.cn/" target="_blank">http://open.t.sina.com.cn/</a><br />
Hammock: <a href="http://hammock.codeplex.com" target="_blank">http://hammock.codeplex.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.binzywu.com/2011/02/windows-phone-7-hammock-oauth-and-sina-weibos-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows Phone Marketplace Tip for 5.6 Technical Support Information</title>
		<link>http://www.binzywu.com/2011/02/windows-phone-marketplace-tip-for-5-6-technical-support-information/</link>
		<comments>http://www.binzywu.com/2011/02/windows-phone-marketplace-tip-for-5-6-technical-support-information/#comments</comments>
		<pubDate>Tue, 01 Feb 2011 21:48:48 +0000</pubDate>
		<dc:creator>binzywu</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[app]]></category>
		<category><![CDATA[marketplace]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[windows phone 7]]></category>
		<category><![CDATA[wp7]]></category>

		<guid isPermaLink="false">http://www.binzywu.com/?p=137</guid>
		<description><![CDATA[OK, it turns out that Microsoft is forcing this policy from the new year, I mean from 2011. My little simple free app&#8217;s update was failed the certification at 5.6, which simply requires you to expose your app&#8217;s version number and your contact information to end users. So if your app has just single page, [...]]]></description>
			<content:encoded><![CDATA[<p>OK, it turns out that Microsoft is forcing this policy from the new year, I mean from 2011. My little simple free app&#8217;s update was failed the certification at 5.6, which simply requires you to expose your app&#8217;s version number and your contact information to end users. So if your app has just single page, probably just put it in some corner and set the opacity lower. If you have multiple pages, adding an about page will be a good idea.</p>
<p>So how about contact info? I tried to add my twitter link to the app, and it just works. From some internal discussion, I would think following information will be OK (not guaranteed&#8230;) since in basic, it just requires you to provide a contact approach for end user to contact/feedback to you.</p>
<ul>
<li>twitter link</li>
<li>a webpage/website</li>
<li>embedded contact form page</li>
<li>email</li>
<li>anything else can find you&#8230;</li>
</ul>
<p>Hope this helps&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.binzywu.com/2011/02/windows-phone-marketplace-tip-for-5-6-technical-support-information/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Is Windows Phone 7 Series the One I Expect?</title>
		<link>http://www.binzywu.com/2010/02/is-windows-phone-7-series-the-one-i-expect/</link>
		<comments>http://www.binzywu.com/2010/02/is-windows-phone-7-series-the-one-i-expect/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 05:12:54 +0000</pubDate>
		<dc:creator>binzywu</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[UI]]></category>
		<category><![CDATA[windows mobile]]></category>
		<category><![CDATA[windows phone 7 series]]></category>
		<category><![CDATA[windows phone7]]></category>
		<category><![CDATA[wp7]]></category>

		<guid isPermaLink="false">http://www.binzywu.com/?p=108</guid>
		<description><![CDATA[Microsoft announced WP7 series on WMC2010. (Announce video: http://www.youtube.com/watch?v=5q-HtdW03Zs, pretty cool!) And there are lots of people are talking about it. But what I expect of a mobile OS? I write this down 9 months ago: 1. Small/Micro kernel. 2. Powerful UI. 3. Simple Application development. And what I can see now is it really has [...]]]></description>
			<content:encoded><![CDATA[<p>Microsoft announced WP7 series on WMC2010. (Announce video: <a href="http://www.youtube.com/watch?v=5q-HtdW03Zs">http://www.youtube.com/watch?v=5q-HtdW03Zs</a>, pretty cool!) And there are lots of people are talking about it. But what I expect of a mobile OS? I write <a href="http://www.binzywu.com/2009/05/mobile-operating-systems/" target="_blank">this</a> down 9 months ago:</p>
<p>1. Small/Micro kernel.<br />
2. Powerful UI.<br />
3. Simple Application development.</p>
<p>And what I can see now is it really has an innovative UI and I like it. The kernel should be neat althought it definitely should be based on Win CE (guess). So what I really want to know is how to develop app based on this new UI. It should bring a tough switch&#8230; But let&#8217;s check it out on <a title="mix10" href="http://live.visitmix.com" target="_blank">MIX10</a>&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.binzywu.com/2010/02/is-windows-phone-7-series-the-one-i-expect/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

