<?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>Idea Manglar</title>
	<atom:link href="http://blog.manglar.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.manglar.com</link>
	<description>{ideas}</description>
	<lastBuildDate>Tue, 08 Jun 2010 08:02:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to connect a Debian machine to a Windows 2008 PPTP VPN</title>
		<link>http://blog.manglar.com/how-to-connect-a-debian-machine-to-a-windows-2008-pptp-vpn/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=how-to-connect-a-debian-machine-to-a-windows-2008-pptp-vpn</link>
		<comments>http://blog.manglar.com/how-to-connect-a-debian-machine-to-a-windows-2008-pptp-vpn/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 08:02:00 +0000</pubDate>
		<dc:creator>Germán Medina</dc:creator>
				<category><![CDATA[Tech Recipes]]></category>

		<guid isPermaLink="false">http://blog.manglar.com/?p=253</guid>
		<description><![CDATA[
#apt-get install pptp-linux
#apt-get install ca-certificates
Copy certificate to /usr/share/ca-certificates . If your certificate extension is .cer then change it to .crt
#dpkg-reconfigure ca-certificates //Select your certificate from the list
Follow the pppt client debian configuration instructions on http://pptpclient.sourceforge.net/howto-debian.phtml
Create a /etc/ppp/ip-up.d/ppp0 with routing information:
#!/bin/sh
/sbin/route add -net 192.168.1.0 netmask 255.255.255.0 dev ppp0
#chmod +x /etc/ppp/ip-up.d/ppp0
Add the next lines to you /etc/ppp/peers/provider ]]></description>
			<content:encoded><![CDATA[<ol>
<li>#apt-get install pptp-linux</li>
<li>#apt-get install ca-certificates</li>
<li>Copy certificate to /usr/share/ca-certificates . If your certificate extension is .cer then change it to .crt</li>
<li>#dpkg-reconfigure ca-certificates //Select your certificate from the list</li>
<li>Follow the pppt client debian configuration instructions on <a href="http://pptpclient.sourceforge.net/howto-debian.phtml">http://pptpclient.sourceforge.net/howto-debian.phtml</a></li>
<li>Create a /etc/ppp/ip-up.d/ppp0 with routing information:<br />
#!/bin/sh<br />
/sbin/route add -net 192.168.1.0 netmask 255.255.255.0 dev ppp0</li>
<li>#chmod +x /etc/ppp/ip-up.d/ppp0</li>
<li>Add the next lines to you /etc/ppp/peers/provider file if you want your connection to be reconnected if it fails and if you want to assign a static ip address to your connection<br />
persist<br />
192.168.1.10:</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.manglar.com/how-to-connect-a-debian-machine-to-a-windows-2008-pptp-vpn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to install Linux Integration Services Version 2.1 on a Hyper-V virtual machine running Debian</title>
		<link>http://blog.manglar.com/how-to-install-linux-integration-services-version-2-1-on-a-hyper-v-virtual-machine-running-debian/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=how-to-install-linux-integration-services-version-2-1-on-a-hyper-v-virtual-machine-running-debian</link>
		<comments>http://blog.manglar.com/how-to-install-linux-integration-services-version-2-1-on-a-hyper-v-virtual-machine-running-debian/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 06:38:42 +0000</pubDate>
		<dc:creator>Germán Medina</dc:creator>
				<category><![CDATA[Tech Recipes]]></category>

		<guid isPermaLink="false">http://blog.manglar.com/?p=250</guid>
		<description><![CDATA[Linux Integration Services Version 2.1 now has support for Timesync, Integrated Shutdown and Symmetric Multi-Processing (SMP) up to 4 virtual processors.

Get the Linux Integration Services 2.1 Beta from https://connect.microsoft.com/site495
Extract the files and insert the .iso as a disk in your virtual machine
Now the hard/long part, update your Kernel with version 2.6.27.47 (This is out of ]]></description>
			<content:encoded><![CDATA[<p>Linux Integration Services Version 2.1 now has support for Timesync, Integrated Shutdown and Symmetric Multi-Processing (SMP) up to 4 virtual processors.</p>
<ol>
<li>Get the Linux Integration Services 2.1 Beta from <a href="https://connect.microsoft.com/site495">https://connect.microsoft.com/site495</a></li>
<li>Extract the files and insert the .iso as a disk in your virtual machine</li>
<li>Now the hard/long part, update your Kernel with version 2.6.27.47 (This is out of scope, so you will have to look for info on how to do this).</li>
<li>Reboot and choose your new Kernel</li>
<li>#mount /cdrom</li>
<li>#mkdir /opt/linux_ic_v21_rc</li>
<li>#cp /cdrom/* /opt/linux_ic_v21_rc -R</li>
<li>#mkdir /etc/sysconfig/network</li>
<li># cd /opt/linux_ic_v21_rc  -R</li>
<li>Modify the Mafile file replacing all the occurrences of <em>—reload-rules</em> with <em>—reload_rules</em></li>
<li>Modify the scripts/updateinitrd.pl file commenting lines 79 to 87 and adding this line after that <em>$initrdfile = &#8220;/boot/initrd.img-2.6.27.47&#8243;;</em>  </li>
<li>Modify scripts/updategrub.pl file replacing line 55 with <em>$grubfile = &#8220;/boot/grub/menu.lst&#8221;;</em></li>
<li>#apt-get install chkconfig</li>
<li>#make</li>
<li>#make install</li>
<li>Modify your /etc/init.d/vmbus file commenting lines 55 to 61 and 108 to 112. Also replace line 73 with <em>return 0</em> and 75 with <em>return 1</em></li>
<li>Modify your /etc/network/interfaces file replacing eth0 with seth0</li>
<li>Modify your /etc/initramfs-tools/modules file adding a <em>vmbus</em> line and a <em>netvsc</em> line</li>
<li>#update-initramfs –u –k 2.6.27.47</li>
<li>Shutdown your virtual machine #init 0</li>
<li>Replace your legacy network adapter with a normal Network adapter copying your old adapter’s MAC to your new adapter</li>
<li>Start your virtual machine</li>
<li>That’s it, now you have a Debian Hyper-V virtual machine with Integration Services.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.manglar.com/how-to-install-linux-integration-services-version-2-1-on-a-hyper-v-virtual-machine-running-debian/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to shrink a database log file in SQL Server 2008</title>
		<link>http://blog.manglar.com/how-to-shrink-a-database-log-file-in-sql-server-2008/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=how-to-shrink-a-database-log-file-in-sql-server-2008</link>
		<comments>http://blog.manglar.com/how-to-shrink-a-database-log-file-in-sql-server-2008/#comments</comments>
		<pubDate>Sat, 22 May 2010 18:46:15 +0000</pubDate>
		<dc:creator>Germán Medina</dc:creator>
				<category><![CDATA[Tech Recipes]]></category>

		<guid isPermaLink="false">http://blog.manglar.com/how-to-shrink-a-database-log-file-in-sql-server-2008/</guid>
		<description><![CDATA[
ALTER DATABASE database SET RECOVERY SIMPLE;
dbcc shrinkfile (database_log, 1);
ALTER DATABASE database SET RECOVERY FULL;

]]></description>
			<content:encoded><![CDATA[<pre class="brush: sql;">
ALTER DATABASE database SET RECOVERY SIMPLE;
dbcc shrinkfile (database_log, 1);
ALTER DATABASE database SET RECOVERY FULL;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.manglar.com/how-to-shrink-a-database-log-file-in-sql-server-2008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to use SSL in a WCF service</title>
		<link>http://blog.manglar.com/how-to-use-ssl-in-a-wcf-service/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=how-to-use-ssl-in-a-wcf-service</link>
		<comments>http://blog.manglar.com/how-to-use-ssl-in-a-wcf-service/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 20:46:09 +0000</pubDate>
		<dc:creator>Germán Medina</dc:creator>
				<category><![CDATA[Tech Recipes]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://blog.manglar.com/?p=199</guid>
		<description><![CDATA[1. Enable SSL configuration on your site
2. Set your binding security mode to Transport.
3. Set you service behavior serviceAuthorization PrincipalPermissionMode to None.

public class ServiceHostFactory : WebServiceHostFactory
    {
        protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
        {
            ServiceHost host = new ServiceHost(typeof(Services), baseAddresses);
            host.Authorization.PrincipalPermissionMode = PrincipalPermissionMode.None;
            ServiceEndpoint endpoint = host.AddServiceEndpoint(typeof(IServices), new WebHttpBinding(WebHttpSecurityMode.Transport), &#34;&#34;);
            endpoint.Behaviors.Add(new WebHttpBehaviorEx());
            return host;
        ]]></description>
			<content:encoded><![CDATA[<p>1. Enable SSL configuration on your site<br />
2. Set your binding security mode to Transport.<br />
3. Set you service behavior serviceAuthorization PrincipalPermissionMode to None.</p>
<pre class="brush: csharp; wrap-lines: false;">
public class ServiceHostFactory : WebServiceHostFactory
    {
        protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
        {
            ServiceHost host = new ServiceHost(typeof(Services), baseAddresses);
            host.Authorization.PrincipalPermissionMode = PrincipalPermissionMode.None;
            ServiceEndpoint endpoint = host.AddServiceEndpoint(typeof(IServices), new WebHttpBinding(WebHttpSecurityMode.Transport), &quot;&quot;);
            endpoint.Behaviors.Add(new WebHttpBehaviorEx());
            return host;
        }
    }
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.manglar.com/how-to-use-ssl-in-a-wcf-service/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to publish WCF services using IIS6</title>
		<link>http://blog.manglar.com/how-to-publish-wcf-services-using-iis6/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=how-to-publish-wcf-services-using-iis6</link>
		<comments>http://blog.manglar.com/how-to-publish-wcf-services-using-iis6/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 01:44:55 +0000</pubDate>
		<dc:creator>Germán Medina</dc:creator>
				<category><![CDATA[Tech Recipes]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[Webservices]]></category>

		<guid isPermaLink="false">http://blog.manglar.com/?p=197</guid>
		<description><![CDATA[1. C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis –i
2. C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe –i
3. Do all the things you normally do on IIS7, you are all set.
]]></description>
			<content:encoded><![CDATA[<p>1. C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis –i<br />
2. C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe –i<br />
3. Do all the things you normally do on IIS7, you are all set.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.manglar.com/how-to-publish-wcf-services-using-iis6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to go beyond PUT and DELETE limitations on RESTful Scenarios</title>
		<link>http://blog.manglar.com/how-to-go-beyond-put-and-delete-limitations-on-restful-scenarios/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=how-to-go-beyond-put-and-delete-limitations-on-restful-scenarios</link>
		<comments>http://blog.manglar.com/how-to-go-beyond-put-and-delete-limitations-on-restful-scenarios/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 04:38:33 +0000</pubDate>
		<dc:creator>Germán Medina</dc:creator>
				<category><![CDATA[Tech Recipes]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[RESTful]]></category>

		<guid isPermaLink="false">http://blog.manglar.com/?p=186</guid>
		<description><![CDATA[One of the biggest problems you will have while implementing RESTful services is that most of today’s browsers and firewalls will not allow PUT and DELETE requests. An easy way to fix this is to add a custom HTTP header to your post requests and send the real method in there. Since Google is using ]]></description>
			<content:encoded><![CDATA[<p>One of the biggest problems you will have while implementing RESTful services is that most of today’s browsers and firewalls will not allow PUT and DELETE requests. An easy way to fix this is to add a custom HTTP header to your post requests and send the real method in there. Since Google is using “X-HTTP-Method-Override” it looks like a smart choice to follow that pattern and use it too.</p>
<p>This simple jquery code shows how to do it in the client side:</p>
<pre class="brush: jscript;">
$.ajax({
    type: &quot;POST&quot;,
    url: serviceURL,
    data: &quot;data&quot;,
    success: function(data, textStatus) { alert(&quot;success&quot;); },
    error: function(xhr, status, error) { alert(&quot;error&quot;); },
    beforeSend: function(xhr) { xhr.setRequestHeader(&quot;X-HTTP-Method-Override&quot;, &quot;DELETE&quot;); }
});
</pre>
<p>This C# code shows how to use the custom header in a WCF server:</p>
<pre class="brush: csharp;">
public String PostProxy(String data)
{
    switch (HttpContext.Current.Request.Headers[&quot;X-HTTP-Method-Override&quot;])
    {
        case &quot;PUT&quot;: return Add(data);
        case &quot;DELETE&quot;: return Delete(data);
        default: return Update(data);
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.manglar.com/how-to-go-beyond-put-and-delete-limitations-on-restful-scenarios/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Big files transfer using WCF services</title>
		<link>http://blog.manglar.com/big-files-transfer-using-wcf-services/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=big-files-transfer-using-wcf-services</link>
		<comments>http://blog.manglar.com/big-files-transfer-using-wcf-services/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 22:15:43 +0000</pubDate>
		<dc:creator>Germán Medina</dc:creator>
				<category><![CDATA[Tech Recipes]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[Webservices]]></category>

		<guid isPermaLink="false">http://blog.manglar.com/?p=178</guid>
		<description><![CDATA[If you need to receive files bigger than 4MB using WCF services you have to change the default configuration in your web.config file to allow the size required.

&#60;system.web&#62;
    &#60;httpRuntime maxRequestLength=&#34;131072&#34; /&#62;
&#60;/system.web&#62;

Note: this should work for any ASP application.
]]></description>
			<content:encoded><![CDATA[<p>If you need to receive files bigger than 4MB using WCF services you have to change the default configuration in your web.config file to allow the size required.</p>
<pre class="brush: xml;">
&lt;system.web&gt;
    &lt;httpRuntime maxRequestLength=&quot;131072&quot; /&gt;
&lt;/system.web&gt;
</pre>
<p>Note: this should work for any ASP application.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.manglar.com/big-files-transfer-using-wcf-services/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Declarative permissions for WCF services</title>
		<link>http://blog.manglar.com/declarative-permissions-for-wcf-services/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=declarative-permissions-for-wcf-services</link>
		<comments>http://blog.manglar.com/declarative-permissions-for-wcf-services/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 22:02:41 +0000</pubDate>
		<dc:creator>Germán Medina</dc:creator>
				<category><![CDATA[Tech Recipes]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Permissions]]></category>

		<guid isPermaLink="false">http://blog.manglar.com/?p=176</guid>
		<description><![CDATA[When you develop WCF services you might want to have some protected and unprotected methods on the same service. To do this you will need to do as follows.
Publish your service on an unprotected area of your site; change your web.config file to do it:

&#60;location path=&#34;services&#34;&#62;
    &#60;system.web&#62;
        &#60;authorization&#62;
            &#60;allow users=&#34;*&#34; /&#62;
        &#60;/authorization&#62;
    &#60;/system.web&#62;
&#60;/location&#62;

Add this line ]]></description>
			<content:encoded><![CDATA[<p>When you develop WCF services you might want to have some protected and unprotected methods on the same service. To do this you will need to do as follows.<br />
Publish your service on an unprotected area of your site; change your web.config file to do it:</p>
<pre class="brush: xml; wrap-lines: false;">
&lt;location path=&quot;services&quot;&gt;
    &lt;system.web&gt;
        &lt;authorization&gt;
            &lt;allow users=&quot;*&quot; /&gt;
        &lt;/authorization&gt;
    &lt;/system.web&gt;
&lt;/location&gt;
</pre>
<p>Add this line of code to your service constructor method:</p>
<pre class="brush: csharp; wrap-lines: false;">
public Service()
{
    Thread.CurrentPrincipal = HttpContext.Current.User;
}
</pre>
<p>Finally use declarative permissions on the service methods you want to protect:</p>
<pre class="brush: csharp; wrap-lines: false;">
[PrincipalPermission(SecurityAction.Demand)]
public String YourMethod()
{
    return String.Empty;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.manglar.com/declarative-permissions-for-wcf-services/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to change ASP MembershipProvider ResetPassword method to provide easier passwords</title>
		<link>http://blog.manglar.com/how-to-change-asp-membershipprovider-resetpassword-method-to-provide-easier-passwords/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=how-to-change-asp-membershipprovider-resetpassword-method-to-provide-easier-passwords</link>
		<comments>http://blog.manglar.com/how-to-change-asp-membershipprovider-resetpassword-method-to-provide-easier-passwords/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 19:43:17 +0000</pubDate>
		<dc:creator>Germán Medina</dc:creator>
				<category><![CDATA[Tech Recipes]]></category>
		<category><![CDATA[ASP]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[MembershipProvider]]></category>
		<category><![CDATA[Password]]></category>

		<guid isPermaLink="false">http://blog.manglar.com/?p=169</guid>
		<description><![CDATA[First of all you don’t. You have to change the GeneratePassword method used in the ResetPassword method. To do this you need to write your own membership provider and override it like in this example:

public class MembershipProvider : System.Web.Security.SqlMembershipProvider
{
    const String UPPER = &#34;ABCDEFGHIJKLMNOPQRSTUVWXYZ&#34;;
    const String LOWER = &#34;abcdefghijklmnopqrstuvwxyz&#34;;
    const String NUMBERS = &#34;1234567890&#34;;
    const ]]></description>
			<content:encoded><![CDATA[<p>First of all you don’t. You have to change the GeneratePassword method used in the ResetPassword method. To do this you need to write your own membership provider and override it like in this example:</p>
<pre class="brush: csharp; wrap-lines: false;">
public class MembershipProvider : System.Web.Security.SqlMembershipProvider
{
    const String UPPER = &quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;;
    const String LOWER = &quot;abcdefghijklmnopqrstuvwxyz&quot;;
    const String NUMBERS = &quot;1234567890&quot;;
    const String SPECIAL = &quot;*$-+?&amp;=!%/&quot;;

    public override string GeneratePassword()
    {
        Random rand = new Random();
        String password = &quot;&quot;;
        List&lt;String&gt; data = new List&lt;String&gt;();
        for (int i = 0; i &lt; 10; i++)
        {
            if ( i &lt; 3 ) data.Add(UPPER[rand.Next(UPPER.Length)].ToString());
            else if ( i &lt; 6 ) data.Add(LOWER[rand.Next(LOWER.Length)].ToString());
            else if ( i &lt; 8 ) data.Add(NUMBERS[rand.Next(NUMBERS.Length)].ToString());
            else if ( i &lt; 10 ) data.Add(SPECIAL[rand.Next(SPECIAL.Length)].ToString());
        }
        while (data.Count &gt; 0)
        {
            int pos = rand.Next(data.Count);
            password += data[pos];
            data.RemoveAt(pos);
        }
        return password;
    }
}
</pre>
<p>Note: After you do this you will not be able to use the IIS7 management for your users.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.manglar.com/how-to-change-asp-membershipprovider-resetpassword-method-to-provide-easier-passwords/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Calling Facebook RESTful API using C# (Without Microsoft Facebook SDK)</title>
		<link>http://blog.manglar.com/calling-facebook-restful-api-using-c-without-microsoft-facebook-sdk/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=calling-facebook-restful-api-using-c-without-microsoft-facebook-sdk</link>
		<comments>http://blog.manglar.com/calling-facebook-restful-api-using-c-without-microsoft-facebook-sdk/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 06:25:37 +0000</pubDate>
		<dc:creator>Germán Medina</dc:creator>
				<category><![CDATA[Tech Recipes]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[REST]]></category>

		<guid isPermaLink="false">http://blog.manglar.com/?p=133</guid>
		<description><![CDATA[To continue with our previous posts about Facebook I’m going explain how to use the RESTful API from C# code. This time I’m writing a console application to read user Facebook’s statuses. This illustrates that you can really use the RESTful API from any application including desktop.
A very important thing you need to do before ]]></description>
			<content:encoded><![CDATA[<p>To continue with our previous posts about Facebook I’m going explain how to use the <a href="http://wiki.developers.facebook.com/index.php/API">RESTful API</a> from C# code. This time I’m writing a <em><strong>console application</strong></em> to read user Facebook’s statuses. This illustrates that you can really use the RESTful API from any application including desktop.<br />
A <em><strong>very</strong></em> important thing you need to do before this code works is to ask your user for authorization to read his stream with offline access as shown in this <a href="http://blog.manglar.com/2009/12/14/how-to-ask-facebook-user-permissions-using-javascript-api/">post</a>. After your user grants your application to have offline access you can read his session_key and use it everywhere because it will never expire.</p>
<p>You can download the source code for this post <a href="http://www.manglar.com/blog/GetFacebookUserStatuses.zip">here</a>.</p>
<p>First we need to write a Class that mimics Status FQL table.</p>
<pre class="brush: csharp;">
public class Status
{
    public String status_id { get; set; }
    public String time { get; set; }
    public String source { get; set; }
    public String message { get; set; }
}
</pre>
<p>Then we create a method to generate our data signature.</p>
<pre class="brush: csharp; wrap-lines: false;">
public static String GetSignature(Dictionary&lt;String, String&gt; parameters)
{
    MD5 md5 = MD5.Create();
    String data = &quot;&quot;;
    String[] keys = parameters.Keys.OrderBy(k =&gt; k.ToString()).ToArray();
    for (int i = 0; i &lt; keys.Length; i++)
    {
        String key = keys[i];
        String value = parameters[key];
        data += key + &quot;=&quot; + value;
    }
    data += &quot;APPLICATION_SECRET&quot;;
    byte[] bytes = md5.ComputeHash(Encoding.UTF8.GetBytes(data));
    String signature = &quot;&quot;;
    foreach (byte b in bytes) signature += b.ToString(&quot;x2&quot;);
    return signature;
}
</pre>
<p>After that we just build our post data, post our request, read our response and deserialize the status objects.</p>
<pre class="brush: csharp; wrap-lines: false;">
static void Main(string[] args)
{
    Dictionary&lt;String, String&gt; parameters = new Dictionary&lt;String, String&gt;();
    parameters.Add(&quot;format&quot;, &quot;json&quot;);
    parameters.Add(&quot;method&quot;, &quot;Fql.query&quot;);
    parameters.Add(&quot;query&quot;, &quot;select status_id, time, source, message from status where uid = USER_ID&quot;);
    parameters.Add(&quot;session_key&quot;, &quot;SESSION_KEY&quot;);
    parameters.Add(&quot;api_key&quot;, &quot;API_KEY&quot;);
    parameters.Add(&quot;v&quot;, &quot;1.0&quot;);
    parameters.Add(&quot;call_id&quot;, DateTime.Now.Ticks.ToString());
    parameters.Add(&quot;sig&quot;, GetSignature(parameters));
    String postData = &quot;&quot;;
    for (int i = 0; i &lt; parameters.Keys.Count; i++)
    {
        String key = parameters.Keys.ElementAt(i);
        String value = parameters[key];
        String param = key + &quot;=&quot; + HttpUtility.UrlEncode(value);
        postData += param;
        if (i &lt; parameters.Keys.Count - 1) postData += &quot;&amp;&quot;;
    }
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(&quot;http://api.facebook.com/restserver.php&quot;);
    request.Method = &quot;POST&quot;;
    request.ContentType = &quot;application/x-www-form-urlencoded&quot;;
    StreamWriter writer = new StreamWriter(request.GetRequestStream());
    writer.Write(postData);
    writer.Close();
    DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(Status[]));
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    Status[] statuses = (Status[])serializer.ReadObject(response.GetResponseStream());
    foreach (Status s in statuses)
    {
        DateTime time = new DateTime(long.Parse(s.time));
        Console.WriteLine(time.ToString() + &quot;, &quot; + s.message);
    }
    Console.ReadLine();
}
</pre>
<p>Note that you can use this approach to call any method in the <a href="http://wiki.developers.facebook.com/index.php/API">RESTful API</a>, not to just make <a href="http://wiki.developers.facebook.com/index.php/FQL">FQL </a>queries.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.manglar.com/calling-facebook-restful-api-using-c-without-microsoft-facebook-sdk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
