Social Media Accounts Integration In MVC Application

As we know we can see the world changing every day around us. Most things are available online and are just a few clicks away. In this tech era the importance of social networks is so damn important and influential. One can easily grow their business, get recognized, share ideas etc. via them very easily.

The main purpose of writing this article isthe  same. Nowadays we can include social media things in common development work, like any other important thing such as coding guidelines, parameters etc. Integration of social media accounts wasn’t that easy before. But these days things have been changed, especially when it comes to Microsoft and MVC applications. There are lots of packages available that allow us to do so. These packages make the integration simple with most social networks like Facebook, Twitter, LinkedIn, Yahoo, Google and Microsoft Client.

Obviously you can extend this with other providers but for now we’ll only go through some of the most famous and useful.

Facebook Integration

First step for Facebook is to retrieve the ConsumerKey and ConsumerSecret (it is based on oAuth).

Just go through this link , and register your application.

After registration you will get a personal dashboard for your app, like this,

dashboard

Now go through your App_Start folder in MVC application and follow these steps-

  • Open AuthConfig.cs File
    [App_Start/AuthConfig.cs]

  • Look for the method RegisterAuth and AuthConfig class into it.

  • Just paste the below code in AuthConfig class, as
    [csharp OAuthWebSecurity.RegisterFacebookClient(appId: "yourAppId", appSecret: "yourAppSecret"); ]

  • That’s All!

Twitter Integration

Twitter is based on oAuth 1.x and is very similar to Facebook. It also needs the ConsumerKey and ConsumerSecret so, for that.

Just go through this link , and register your application. After registering to it you will get “ConsumerKey” and “Consumer Secret”.

details

Now go through you App_Start folder in MVC application and follow these steps (like Facebook):

  • Open AuthConfig.cs File
    [App_Start/AuthConfig.cs]

  • Look for the method RegisterAuth and AuthConfig class into it.

  • Just paste the below code in AuthConfig class, as
    [csharp OAuthWebSecurity.RegisterTwitterClient(consumerKey: " yourConsumerKey", consumerSecret: "yourConsumerSecret");]

  • That’s All!

Google+ Integration

This is the simplest integration because you don’t even need any registration. So just go to AuthConfig.cs File and add the below code,

[ csharp OAuthWebSecurity.RegisterGoogleClient(); ]

Linkedin Integration

The initials are same for linkedin too, so am just coming to the point and showing some quick steps to do that.

Just go through-- https://www.linkedin.com/secure/developer?newapp= and register your application. After that you will get- “yourKey” and “yourSecret”.

application

(RegPage)

Now, just follow the same steps like Facebook and Twitter and paste the below code in AuthConfig.

[ csharp OAuthWebSecurity.RegisterLinkedInClient("yourKey", "yourSecret"); ]

Wrapping-Up

That’s all for this part. Let me know if you want any more.

Read more articles on MVC:

Next Recommended Readings