Great Ideas. Always Flowing.

We are not happy until you are happy. Client satisfaction guaranteed. Whatever your needs and requirements, we have the skills and resources for the job!

Popular Tags...

Tags

SnowCovered Top Sellers

Frustrated over the lack of customization for your user's registration fields? Dynamically setup your DNN Portal with custom registration fields, layout, questions, and other core integration options......

Ultra Video Gallery is a brother product of Ultra Media Gallery, UVG allows you to upload videos in various format and automatically encode them to flv or H264 format, you also can add videos from internet or record live videos from your webcam.

Build high performance, completely customizable data-entry forms and views driven by your DNN and external databases. New built-in tools make it a snap to quickly create data entry forms, data views, and even database tables. Plus, add your own HTML, CSS, Javascript, SQL commands, stored procedures,

The most advanced DotNetNuke shopping cart on the planet. Easy to use e-Commerce, Secure Shopping Cart Software and SEO friendly. B2C / B2B Ecommerce Sites.

One stop solution for events calendar and events registration! FREE DOWNLOAD is available now!

Facebook API/SDK within ASP.NET

Configuring and Developing with Facebook API/SDK within ASP.NET (full source code attached bleow)

 

Download Facebook API Source Code for this (must register first, registration is free!)

Facebook has provided a creative way of social networking since it has opened itself up for application development. Since then a large number of applications have started adding to the user’s Facebook experience. It has provided an exciting new platform for application developers to showcase there talents. Looking at the popularity of this platform, Microsoft released Facebook developer Toolkit to facilitate the development of Facebook applications using the Microsoft Visual Studio 2008(2005 not supported as FDT V2.0 requires .Net V3.5). However, the applications which are still on .NET 2.0 and below can use earlier version of the Facebook developer toolkit i.e. V1.2.

 

Facebook .NET Developer Kit

Facebook .Net Developer kit contains full source code in both .Net languages (Visual Basic and Visual C#). It also contains several sample programs for each and every Facebook SDK controls. It is built with Drag and Drop controls support for VS 2008.

 

  • Full source code in both the .NET languages Visual Basic and Visual C#
  • Samples Programs for each and every Facebook SDK controls
  • Samples available for Windows Forms, and also for Microsoft Vista WPF
  • Built with Popfly Technology
  • Drag and Drop controls supported to Facebook comes with VS 2008.
  • FacebookService API
  • Album Class
  • Photo Class
  • FacebookEvent Class
  • Group class
  • Group User class
  • User Class
  • SchoolHistory Class  
  • HighSchool Class
  • HighEducation Class
  • Network Class
  • Location Class
  • Work Class
  • AsyncFacebook Services.
  • Photo API
  • Canvas Base pages to Facebook.WebControls
  • Ajax samples with IFrame
  • Silverlight Examples with IFrame
  • New PublishStory and PublishAction interfaces
  • CreateAlbum Interface
  • GetFriendsNonAppUsers methods

 

By using this SDK we can build Facebook applications of two varieties:

IFrame and FBML base application. We will study more about this application as we proceed through this article.

 

Setting up Facebook Developer Account

For creating the face book application we have to first set the developer account:

1)    First of all we have to create a Facebook account if we don’t have one already.

2)    We have to add a Developer Application to our account.

3)    Once you've installed the Developer app click Developer application from the left column and click Set Up New Application

 

4)      Enter the Application Name and agree to the TOS and click Save Changes.

 

 

5)    On the Canvas options tab :

a.    Set Canvas Page URL for your application

b.    Set Canvas Callback URL : Set the canvas callback url as “http://hosts_file_alias/<your_app_name>/..”
NOTE: Facebook has recently stopped supporting localhost as a valid callback URL. To workaround this problem you can add an alias to your %SystemRoot\System32\drivers\etc\hosts file that refers to localhost as suggested here. Using localhost makes it easy for you to debug locally, note that the port number (nnnn) will be the port you use to debug your application locally using Microsoft's development web server. (Ex: In our case we can set it to http://localhost:/greetuser/default.aspx)

c.    Set Render Method to FBML (It will depend upon the type of application you are building).

6)    Click Save changes. For more information about each of the Options in Facebook application please click here

 

 

Our First Facebook Application

 

 

 

 

Step 4: Setting up the Web.config. Right Click on the websit link name in the solution explorer and select Add New Item from the right click context menu. Now select Web.config file from the Add New Item dialog box. Now Double click on the Web.config file and open it. In the configuration tag of this file you will find a closed tag for application settings (“<appSettings/>”), replace it with the following code.

 

<appsettings>  

<add key="APIKey" value="your API key"></add>  

      <add key="Secret" value="your secret key "></add>  

      <add key="Callback" value="http://www.yourwebsite.com/"></add>  

</appsettings>

 

You might need to go back to the Developer application in the Facebook to retrieve the values for the API Key the Secret and the Callback URL.

 

Step 5: In the source of default.aspx page add following line of code under the form tag as follows

 

<form id="form1" runat="server">

    <table id="table1" cellpadding="0" cellspacing="10" width="100%">

        <tr>

            <td colspan="2">

                <div>

                    <asp:Button ID="btnLogin"  runat="server" Text="Login" OnClick="btnLogin_Click" />

                </div>

            </td>

        </tr>

        <tr>

            <td colspan="2">

                 <asp:Label ID="lblGreet" Visible ="false" runat="server" Text="Hello" Width="112px"></asp:Label>

                    <asp:Label ID="lblUserName" Visible="false" runat="server" Width="184px"></asp:Label>

            </td>

        </tr>   

</form>

 

Step 6: Click open the default.aspx.cs file in the editor. For the scope of our current application we will add the following user directive in the application:

 

using facebook;

using System.Xml.Linq;

 

Step 7: Define an object of type Facebook services in our Default.aspx.cs class as follows

 

protected facebook.Components.FacebookService _fbService = new facebook.Components.FacebookService();

This object will allow us to access all the properties and functions of the Facebook class. Now in the Page load event add the following code snippet.

  protected void Page_Load(object sender, EventArgs e)

 {

          //Set the values for our Facebook service object's properties from our

          //web config file constants(specific to our application).        

         _fbService.ApplicationKey = ConfigurationManager.AppSettings["AppKey"];

        _fbService.Secret = ConfigurationManager.AppSettings["Secret"];

        _fbService.IsDesktopApplication = Convert.ToBoolean(ConfigurationManager.AppSettings["Desktop"]);

 

        try

        {

         string sessionKey = Session["facebook_session_key"] as String;

         string userId = Session["facebook_userId"] as String;

 

         // will will have the auth_token in the query params

         string authToken = Request.QueryString["auth_token"];

           

         //We have already established a session on behalf of this user

            if (!String.IsNullOrEmpty(sessionKey))

            {

                _fbService.SessionKey = sessionKey;

                _fbService.uid = Convert.ToInt64(userId);

               

            }

            // This will be executed when Facebook login redirects to our page

            else if (!String.IsNullOrEmpty(authToken))

            {

                _fbService.CreateSession(authToken);

                Session["facebook_session_key"] = _fbService.SessionKey;

                Session["facebook_userId"] = _fbService.uid.ToString();

                Session["facebook_session_expires"] = _fbService.SessionExpires;

            }

 

        }       

        catch (Exception ex)

        {           

            lblUserName.Text = ex.Message.ToString();         

        }

 

 

This function will first authenticate user and then shows the greeting along with the name of the user for the valid user. Here we are first of all setting the values for our API’s ApplicationKey, Secret and IsDesktopApplication properties. Then after authenticating the user we check if we have a valid userId which is passes to our application by the Facebook when we login in our application using our facebook account. When we have a valid user we can excess the  _fbService.users Class and using its getInfo method we can obtain our user’s first name and last name.

 

Setp 8: Now the last step is to add the event on the click of the login button. Now write the following line of code in the btnLogin_Click function.

 

protected void btnLogin_Click(object sender, EventArgs e)

    {

        Response.Redirect(@"http://www.facebook.com/login.php?api_key=" +

       _fbService.ApplicationKey + @"&v=1.0");

    }

 

This will redirect the user to the facebook login page hence will facilitate to authenticate the user.That’s it now you can compile and run your application.

 

Extracting User Profile Details and Friends List for the user:

FaceBook API exposes verious classes, properties and Methods on top of which we can build our applications. To give you an idea about the various classes and methods which we can utilize, here we are extending our application to show the logged on user’s profile and the friends list from facebook.

 

As we are only extending our previous application here so we can jump directly on step 5 and add the controls that we need on the form.

 

Step 5: In the source of default.aspx page add following line of code under the form tag as follows

 

<tr>

<td width="50%">

                <cc1:UserProfile ID="UserProfile1" Visible="false" runat="server" /></td>

        <td><asp:ListBox ID="lstFriends" runat="server" Visible="false"></asp:ListBox></td>

 </tr>

 

Here we are using the facebook’s inbuilt web control for showing the user profile.

 

Step 6:It will remain the same as above, but now as we have to show the friends list, for which we will be using the IList type of object and so we need to add one more user directives in our Default.aspx.cs class.

 

using System.Collections.Generic;

Step 7: As Facebook provides its own inbuilt web control for displaying the user profile. For showing the friends list in a listbox we have to first collect the Id’s of all the friends of the user from the friends class of Facebook API and then obtaining the Info of each friend by passing there Ids to the _fbService.users.getInfo() Method. Once we have the information of a friend we can add their name to our list box. Using the listbox’s

String uids = String.Empty;

        IList<facebook.Schema.user> userFriendsInfo;

 

        friends friendUid = new friends(_fbService.API);

        IList<long> ids = friendUid.get();

 

        for (int i = 0; i < ids.Count; i++)

        {

            uids = uids + "," + ids[i];

        }

 

        if (uids != String.Empty)

        {

            userFriendsInfo = _fbService.users.getInfo(uids);

 

            foreach (facebook.Schema.user u in userFriendsInfo)

            {

                lstFriends.Items.Add(u.name);

            }

 

Step 8: Just compile and run your application now. You should be able to see the logged on user’s profile and list of friends in the list box.

Some Common problems

First and the most important thing that I have mentioned above as well is that this API/ SDK V2.0 works with .NET framework 3.5 and above. So if you want to work with VS 2005 then make sure either you have .Net V3.5 installed on you machine or you have to use older version of the toolkit.

 

Secondly a very handy thing that the Facebook API classes provide is the freedom to utilize the user profile XML in your application. Facebook API method _fbService.users.getInfo() return IList type value. So you need to write a method to conver IList to  List type so that the new type can be serialized to XML.

 

Also if your application has anything to do with the messaging, notification or emailing, then you might want to check for the conditions that Facebook has forced upon the useage of these classes. All the information that you need in this regard can be obtained from the following hyperlink Facebook Developers wiki

 

Happy Programming!!

 

Download Facebook API Source Code for this (must register first, registration is free!)

 

Share the page?

Developing with Facebook API/SDK w/ ASP.NET - share this page - email email - del.icio.us del.icio.us - digg digg - reddit reddit

Feedback Comments

Feedback

SharePoint Web Parts


All Data Springs Web Parts Support WSS 3.0, SharePoint 2007, and SharePoint 2010 Frameworks

Please select license option for each web part you wish to purchase. We highly recommend the SharePoint Bundle to get all Data Springs Web Parts for maximum value!

 

 

      
Cart


Data Springs Sharepoint Bundle

Best Value! The Bundle gives you all 5 web parts in one package at a very attractive price! Best Value! We think you will be very happy with the SharePoint bundle and great price discounts you will receive. With your purchase all of the web parts below will be included.
 
 
 
 

Random Image Web Part

With Random Image for Sharepoint 2007, you can select multiple images to display randomly when the web part loads...
 
 
 
 

Stock Quote Web Part

Giving your site visitors relevant information is critical. With the Data Springs Stock Web Part you can provide your users with up to date financial information
 
 
 
 

Dynamic Image Rotator Web Part

Who would have thought? Adobe Flash® with Sharepoint! The FIRST and ONLY image rotation web part for Sharepoint using Flash Technology from Adobe! The Dynamic Image Rotator displays selected images and then rotates between the images. Several extended and optional features allow you to select the time to rotate each image, fade between
 
 
 
 

SharePoint Charts Web Part

The MOSS Chart Web Part is a web part built by Data Springs for the purpose of rendering several chart types based on data from a SharePoint list on a MOSS 2007 or WSS 3.0 Site
 
 
 
 

Dynamic News Ticker Web Part

Provide current news items with a user-friendly news ticker for your Sharepoint Portal. With millions of web sites offering information you need a fun way to display information and the solution is Flash News Ticker....
 
 
 
 

Tailored Text Web Part

 Tailored Text Web Part allows you to add text/html to your web site that can be different for anonymous users, registered users,  and even individual users specifically.

 
 
 
 

Dynamic Views Web Part

Dynamic Views is an excellent tool to:
Personalization allows you to go the extra mile in communicating or connecting one to one with your clients. When it comes to technology and web site content, you now have the power to leverage this personalization directly with your users on your DotNetNuke® site

 
 
 
 

Dynamic Login Web Part

Your site content isn't vanilla, so why is your portal's login?

Add pizazz and functionality with Dynamic Login! Use custom templates, localization, redirection rules for various roles and many more features!
 
 
 
 


DNN Modules

DotNetNuke Modules


Data Springs offers cost-saving packages that fit your needs:

Purchase the Collection 6.0

Data Springs Collection 6.0

An entire tool chest to quickly build websites and construct complex, powerful, and relevant workflow. Elevate your design with custom registration, forms, displays, reports, user management, payments, Google maps,, SQL updates, and so much more!

Best Value!  Includes all DotNetNuke modules by Data Springs.

$ 495.00

Data Springs User Management Suite 3.0

All the tools you need to enhance user & profile management from A to Z!.  A comprehensive package with 5 feature-packed modules that offer extensive admin controls and easy user interface geared towards an effective and growth-oriented site!  .... more

 

Includes:  Dynamic Registration     Dynamic Login   ♦   Interactive User Import     Dynamic User Directory   ♦   Renewal Reminder    A value of more than $630.00!

 $ 369.00

 

 

Check out all our individual modules!

 

 View Dynamic Registration

Dynamic Registration 5.0 (new release on 6/12/2013)

Need custom fields and workflow for your registration? Get all the power and ease of use to create the registration and profile management just the way you want it... more

$ 199.00

View Dynamic Forms

Dynamic Forms 4.1 (released 5/16/2012)

Whether it's for marketing, sales, contact forms, scheduling, information requests, surveys, or to simply better understand your customer needs, the possibilities for creating powerfully effective forms are now easy and endless! ... more

$ 195.00

 

Dynamic Views 3.1 (new on 2/7/2013)

Now have an easy yet feature-rich reporting module with custom defined display templates and unlimited search options from  Dynamic Forms or any data source like a table, view or custom query!  ... more

$ 169.00

 View Dynamic Login Module

Dynamic Login 4.1 (released 10/19/2011)

Add pizazz and functionality to your site login! Dynamic Login gives you custom templates, localization, redirection rules, SQL Validation, and Single SignOn. Want more? How about Facebook Connect, LinkedIN, and Twitter, too? Your login has never been so exciting!.   ... more

$ 149.00

 View Interactive User Import

Interactive User Import 3.0 (released 8/17/2011)

Interactive User Import provides you with the functionality to easily and quickly import users into DotNetNuke and Dynamic Registration, through a streamlined and well-documented wizard that includes many advanced features... more

$ 149.00

 View Dynamic User Directory

Dynamic User Directory 4.1 (released 4/26/2012)

The perfect compliment for extending your portals users and community! An essential ingredient for managing dynamic user information, is being able to sort key fields and create useful user directories and custom report information... more

$ 179.00

 View Renewal Reminder

Renewal Reminder 1.3

Renewal Reminder provides you with the functionality to setup email notifications for users that their security role will soon expire. After installing your renewal / security role reminder module you can now setup scheduled notifications to be distributed to your users... more

$ 129.99
 View Opt In Email

Opt In Email 5.0 (new on 4/17/2013)

'Relationship Building' and 'Communication' are two essential nuts and bolts for a business to prosper. This module allows you to bridge both of these and easily generate continuous awareness of your web site, products and services. Your prospects and customers will greatly appreciate this feature... more

$ 179.00

 View Tailored Text

Tailored Text 3.0

Personalization allows you to go the extra mile in communicating or connecting one to one with your clients. Leverage the power personalized content on your DotNetNuke site... more

$ 109.99
 View Stock Quote

Stock Quote 1.2

Giving your site visitors relevant information is critical. With the Data Springs Stock Module you can provide your users with up to date financial information... more

$ 109.99
 View Presentation Archive

Presentation Archive 2.0

With so much content on your web site, its important to give users an easy method for finding and retrieving content. Presentation Archive allows you to categorize, organize and present content within your DotNetNuke site for presentations, educational material, videos, and almost any document... more

$ 124.99
 View Real Estate

Real Estate 2.3

Real Estate 2.3 is a feature rich and user-friendly module that allows your portal users the ability to create real estate listings on your site... more

$ 149.99
 View Dynamic Image Rotator

Dynamic Image Rotator 3.3

Dynamic Image Rotator displays selected images and then rotates between the images using the Adobe® Flash® platform.  Several extended and optional features allow you to select the time to rotate each image, fade between images, and also display the images in either sequental or random order... more

$49.99
 View Info Pics Gallery

Info Pics Gallery

The Info Pics Gallery Module allows you to display thumbnail pictures with information to the user about each picture, along with a detailed description regarding the set of pictures and several other optional links... more

 $ 69.99
 View Testimonials Module

Testimonials

The Testimonials Module allows you to display customer testimonials on your site, as well as an easy method for users to submit testimonials about your web site, services, or products... more

 $ 49.99
 View Dynamic Info Cube

Dynamic Info Cube

Take your web site out of the box! Looking for a creative and interesting way to showcase information and content on your site? With millions of web sites offering information you need a fun way to display information and the solution is Dynamic Info Cube... more

$ 99.95
 Search Engine Optimization Cloud Module for DotNetNuke

Dynamic Tags

Nearly every web site developer would agree that search engine optimization is one of key aspects to a successful web site. Part of search engine optimization requires providing search engines that crawl your web site with appropriate and meaningful content... more

$ 69.99
 View Page Tags

Page Tags

'Page Tags' pulls in search terms that users searched to find the current page. There are many benefits to displaying these search words that delivered the user to the site, find our more details ... more

$ 59.99
 Random Rounded Images

Random Rounded Images

Random Rounded Images is an easy to use upgraded version of the images module included with DNN. With RRI, you can select multiple images to display randomly when the module loads. For example, you can add 10 images to the module, and each time you refresh or load the page one of those images will... more

$ 49.99
 View Back on Track

Back on Track

Giving your site visitors fast access to areas of interest is vital to your web site's ease of use and ultimately - sales potential... more

$ 99.99
 

Dynamic News Ticker 2.0

Dynamic News Ticker allows you to scroll through news items in a horizontal or veritical direction with administrative features that allow you to easily customize the look of your news ticker. Each instance of Dynamic News Ticker can be set up to have different sizes, scroll directions, scroll speed... more

$ 39.00
 View Quick Poll

Quick Poll

Give your users a voice, while also providing an important way for you to gather opinions from your users and measure visitors' responses to questions on your site! Polls are significant because they can provide a way for your web site visitors to share ideas and vote on topics of your choosing... more

$ 39.99
 View Flash Contacts

Dynamic Contacts 2.0

Dynamic Contacts is the fastest and easiest way you can help visitors of your website connect with your key personnel... more

$ 79.99
     

 

 

 
 

Join our mailing list...

Get current news and events the easy way
 
 
   
Subscribe Me

Recent Blogs...

 
Copyright 2005 - 2011 by Data Springs, Inc.