<?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>Frederik Vig - ASP.NET developer &#187; .NET</title>
	<atom:link href="http://www.frederikvig.com/category/net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.frederikvig.com</link>
	<description></description>
	<lastBuildDate>Wed, 28 Jul 2010 14:08:42 +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>SlideShare .NET API Wrapper</title>
		<link>http://www.frederikvig.com/2009/10/slideshare-net-api-wrapper/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=slideshare-net-api-wrapper</link>
		<comments>http://www.frederikvig.com/2009/10/slideshare-net-api-wrapper/#comments</comments>
		<pubDate>Sun, 18 Oct 2009 13:29:58 +0000</pubDate>
		<dc:creator>Frederik Vig</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[SlideShare]]></category>

		<guid isPermaLink="false">http://www.frederikvig.com/?p=322</guid>
		<description><![CDATA[In a recent project I had to work with the SlideShare API. Thankfully there was some good documentation to get me started, and even a .NET wrapper for the first version of the API. From SlideShare SlideShare is a business media site for sharing presentations, documents and pdfs. After downloading and playing around with the [...]]]></description>
			<content:encoded><![CDATA[<p>In a recent project I had to work with the <a href="http://www.slideshare.net/developers">SlideShare API</a>. Thankfully there was some good <a href="http://www.slideshare.net/developers/documentation">documentation</a> to get me started, and even a <a href="http://www.slideshare.net/developers/apikits">.NET wrapper for the first version of the API</a>. </p>
<blockquote><p>
<cite><a href="http://www.slideshare.net/about">From SlideShare</a></cite></p>
<p>SlideShare is a business media site for sharing presentations, documents and pdfs.</p>
</blockquote>
<p>After downloading and playing around with the code I decided to upgrade it to version 2 of the API. I encourage you to take a look at the documentation if you haven&#8217;t, to see what&#8217;s new in version 2 of the API, and what&#8217;s available.</p>
<h3>SlideShare API Wrapper Methods</h3>
<p>Here are the methods that I&#8217;ve exposed and made available for you to use. Big thanks to <a href="http://www.briangrinstead.com/blog/about">Brian Grinstead</a> for his blog post <a href="http://www.briangrinstead.com/blog/multipart-form-post-in-c">Multipart Form Post in C#</a> and for <a href="http://groups.google.com/group/slideshare-developers/web/slideshare-api-in-net-sample-code">Gaurav Gupta</a> for creating the wrapper class for the first version, which this code is based on.</p>
<ul>
<li>GetSlideshow</li>
<li>GetSlideshowsForTag</li>
<li>GetSlideshowsForGroup</li>
<li>GetSlideshowsForUser</li>
<li>SlideshowSearch</li>
<li>GetUserGroups</li>
<li>GetUserContacts</li>
<li>GetUserTags</li>
<li>EditSlideshow</li>
<li>DeleteSlideshow</li>
<li>UploadSlideshow</li>
</ul>
<p>To use it simply download the code (see link at the bottom of this post), copy the SlideShareAPI.dll into your bin folder and make a reference to it in your project. After you&#8217;ve done that you&#8217;ll be able to create an instance of the SlideShare class which will expose the methods above.</p>
<p>Remember that you also need  an API Key and Shared Secret. Go to the <a href="http://www.slideshare.net/developers/applyforapi">Apply for API Keys page</a> and fill out the form. You should then receive an email with both keys. </p>
<h3>Example</h3>
<p>Lets get some slideshows that are tagged with web, bind them to a Repeater control and display them to the user.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Linq</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Xml.Linq</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">SlideShareAPI</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">namespace</span> FV.<span style="color: #0000FF;">Templates</span>.<span style="color: #0000FF;">FV</span>.<span style="color: #0000FF;">Pages</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">partial</span> <span style="color: #FF0000;">class</span> SlideShareTest <span style="color: #008000;">:</span> <span style="color: #000000;">System.<span style="color: #0000FF;">Web</span>.<span style="color: #0000FF;">UI</span></span>.<span style="color: #0000FF;">Page</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">override</span> <span style="color: #0600FF;">void</span> OnLoad<span style="color: #000000;">&#40;</span>EventArgs e<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">base</span>.<span style="color: #0000FF;">OnLoad</span><span style="color: #000000;">&#40;</span>e<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            var slideShare <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> SlideShare<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;API Key&quot;</span>, <span style="color: #666666;">&quot;Shared secret&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            var xml <span style="color: #008000;">=</span> XElement.<span style="color: #0000FF;">Parse</span><span style="color: #000000;">&#40;</span>slideShare.<span style="color: #0000FF;">GetSlideshowsForTag</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;web&quot;</span>, <span style="color: #FF0000;">0</span>, <span style="color: #FF0000;">10</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            var slideshows <span style="color: #008000;">=</span> from slideshare <span style="color: #0600FF;">in</span> xml.<span style="color: #0000FF;">Elements</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Slideshow&quot;</span><span style="color: #000000;">&#41;</span>
                            select <span style="color: #008000;">new</span>
                            <span style="color: #000000;">&#123;</span>
                                Title <span style="color: #008000;">=</span> slideshare.<span style="color: #0000FF;">Element</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Title&quot;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Value</span>,
                                Description <span style="color: #008000;">=</span> slideshare.<span style="color: #0000FF;">Element</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Description&quot;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Value</span>,
                                EmbedCode <span style="color: #008000;">=</span> slideshare.<span style="color: #0000FF;">Element</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Embed&quot;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Value</span>
                            <span style="color: #000000;">&#125;</span><span style="color: #008000;">;</span>
&nbsp;
            rptSlideshows.<span style="color: #0000FF;">DataSource</span> <span style="color: #008000;">=</span> slideshows<span style="color: #008000;">;</span>
            rptSlideshows.<span style="color: #0000FF;">DataBind</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>I use Linq to XML and create anonymous objects that I then databind to my Repeater.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&lt;%</span>@ Page Language<span style="color: #008000;">=</span><span style="color: #666666;">&quot;C#&quot;</span> AutoEventWireup<span style="color: #008000;">=</span><span style="color: #666666;">&quot;true&quot;</span> CodeBehind<span style="color: #008000;">=</span><span style="color: #666666;">&quot;SlideShareTest.aspx.cs&quot;</span> Inherits<span style="color: #008000;">=</span><span style="color: #666666;">&quot;FV.Templates.FV.Pages.SlideShareTest&quot;</span> <span style="color: #008000;">%&gt;</span>
&nbsp;
<span style="color: #008000;">&lt;!</span>DOCTYPE html <span style="color: #0600FF;">PUBLIC</span> <span style="color: #666666;">&quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;</span> <span style="color: #666666;">&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;</span><span style="color: #008000;">&gt;</span>
&nbsp;
<span style="color: #008000;">&lt;</span>html xmlns<span style="color: #008000;">=</span><span style="color: #666666;">&quot;http://www.w3.org/1999/xhtml&quot;</span> <span style="color: #008000;">&gt;</span>
<span style="color: #008000;">&lt;</span>head runat<span style="color: #008000;">=</span><span style="color: #666666;">&quot;server&quot;</span><span style="color: #008000;">&gt;</span>
    <span style="color: #008000;">&lt;</span>title<span style="color: #008000;">&gt;&lt;/</span>title<span style="color: #008000;">&gt;</span>
<span style="color: #008000;">&lt;/</span>head<span style="color: #008000;">&gt;</span>
<span style="color: #008000;">&lt;</span>body<span style="color: #008000;">&gt;</span>
    <span style="color: #008000;">&lt;</span>form id<span style="color: #008000;">=</span><span style="color: #666666;">&quot;form1&quot;</span> runat<span style="color: #008000;">=</span><span style="color: #666666;">&quot;server&quot;</span><span style="color: #008000;">&gt;</span>
    <span style="color: #008000;">&lt;</span>asp<span style="color: #008000;">:</span>Repeater runat<span style="color: #008000;">=</span><span style="color: #666666;">&quot;server&quot;</span> ID<span style="color: #008000;">=</span><span style="color: #666666;">&quot;rptSlideshows&quot;</span><span style="color: #008000;">&gt;</span>
    <span style="color: #008000;">&lt;</span>HeaderTemplate<span style="color: #008000;">&gt;&lt;</span>ul<span style="color: #008000;">&gt;&lt;/</span>HeaderTemplate<span style="color: #008000;">&gt;</span>
    <span style="color: #008000;">&lt;</span>ItemTemplate<span style="color: #008000;">&gt;</span>
        <span style="color: #008000;">&lt;</span>li<span style="color: #008000;">&gt;</span>
        <span style="color: #008000;">&lt;</span>h3<span style="color: #008000;">&gt;&lt;%</span><span style="color: #008080;"># HttpUtility.HtmlEncode(Eval(&quot;Title&quot;).ToString()) %&gt;&lt;/h3&gt;</span>
        <span style="color: #008000;">&lt;</span>p<span style="color: #008000;">&gt;&lt;%</span><span style="color: #008080;"># HttpUtility.HtmlEncode(Eval(&quot;Description&quot;).ToString()) %&gt;&lt;/p&gt;</span>
        <span style="color: #008000;">&lt;%</span><span style="color: #008080;"># HttpUtility.HtmlDecode(Eval(&quot;EmbedCode&quot;).ToString())%&gt;</span>
        <span style="color: #008000;">&lt;/</span>li<span style="color: #008000;">&gt;</span>
    <span style="color: #008000;">&lt;/</span>ItemTemplate<span style="color: #008000;">&gt;</span>
    <span style="color: #008000;">&lt;</span>FooterTemplate<span style="color: #008000;">&gt;&lt;/</span>ul<span style="color: #008000;">&gt;&lt;/</span>FooterTemplate<span style="color: #008000;">&gt;</span>
<span style="color: #008000;">&lt;/</span>asp<span style="color: #008000;">:</span>Repeater<span style="color: #008000;">&gt;</span>
    <span style="color: #008000;">&lt;/</span>form<span style="color: #008000;">&gt;</span>
<span style="color: #008000;">&lt;/</span>body<span style="color: #008000;">&gt;</span>
<span style="color: #008000;">&lt;/</span>html<span style="color: #008000;">&gt;</span></pre></div></div>

<p>Most of the code is commented and available through Visual Studio Intellisense. You can also go through and change the code to your needs.</p>
<p><a href="http://www.frederikvig.com/wp-content/uploads/slideshare/SlideShareAPI.zip">Download the code</a><strong>Related Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.frederikvig.com/2009/10/slideshare-dynamic-content/" rel="bookmark" title="October 25, 2009">SlideShare Dynamic Content</a></li>
<li><a href="http://www.frederikvig.com/2009/11/epicode-extensions-new-epicode-community-project/" rel="bookmark" title="November 1, 2009">EPiCode.Extensions new EPiCode Community Project</a></li>
<li><a href="http://www.frederikvig.com/2009/05/css-tricks-part-1/" rel="bookmark" title="May 31, 2009">CSS tricks &#8211; part 1</a></li>
<li><a href="http://www.frederikvig.com/2010/03/updated-all-episerver-posts-for-episerver-cms-6/" rel="bookmark" title="March 28, 2010">Updated all EPiServer posts for EPiServer CMS 6</a></li>
<li><a href="http://www.frederikvig.com/2009/07/episerver-web-controls-pagelist/" rel="bookmark" title="July 20, 2009">EPiServer web controls: PageList</a></li>
</ul>
<p><!-- Similar Posts took 13.105 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.frederikvig.com/2009/10/slideshare-net-api-wrapper/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->