The big social networks like Twitter, YouTube, Facebook and Flickr want to induce people to interact with their network every day. So in addition to their sites and their own mobile apps, social networks often open up Web API’s to make it possible for developers of any application or website to integrate social features. And with the power of Visual Studio Community 2015 Edition (VSCE), tapping into those API’s is a cinch.
In this article you will learn what’s involved in writing ASP.NET MVC Web applications in C# that leverage social network API features. First you’ll get a taste for the features provided by various sites and the data you can tap into using their API. Then you’ll get a chance to dive deeper and write your own C# code using Visual Studio Community 2015 Edition. By connecting with the YouTube API, you’ll jazz-up your app with flashy features in minutes, rather than weeks.
If you aren’t familiar with Visual Studio Community 2015 Edition, you can download it freely from Microsoft. You can see “Getting a Free, Yet Powerful Web Dev Tool: Visual Studio Community 2015 Edition” to learn how to download and install it.
So what’s Out There?
Web API’s have been around for years now and there are plenty available from names you already know: Facebook, Twitter, Flickr, YouTube and many more. In the next few sections, I’ll show you what these big names are up to and the features their API’s offer.
Officially launched in 2007, the Facebook Platform provides a host of social networking services. The centerpiece of the platform is the Graph API. No, it doesn’t do pie charts and scatter graphs. Rather, this interface provides access to Facebook information using the concept of objects or nodes that contain information (like a user or a photo) and fields within the node that provide information about it (a user’s name and email address). Finally edges are connections between the nodes. With this basic structure, the API allows you to query data, post to a user’s timeline, upload photos and many other tasks. You’re user get a new high score! Why not offer to post a brag on their timeline?
An important part of the Graph API is its authentication features. Of course to post on a user’s behalf you must have them log in and give your app permission. But another use many apps make of the authentication features of Facebook is to provide a kind of single-sign-in solution. A mobile app, for example, may ask you to register before you can use their online features. Instead of creating (yet another) username and password to remember, it asks if you’d prefer to log in using your Facebook credentials.
Another interface provided by Facebook is the Marketing API. This allows developers to integrate features like ad management, marketing analytics and management of your company’s Facebook assets, like pages, accounts, apps, etc.
For more information on Facebook APIs and SDKs, check out https://developers.facebook.com/docs/apis-and-sdks.
Twitter’s simplicity and enforced brevity have catapulted this service to Internet stardom, accepting and broadcasting over 200 million tweets a day. The Twitter REST API methods provides features to post/reply to tweets, favorite tweets, re-tweet and even upload images and videos. In addition, apps can (with permission) access and update the user’s timeline, status and user information. Twitter also has a Search API to give your application access to Twitter Search features and trend data.
Finally, if you want to tap into the Twitter firehose to create a data mining or analytics application, Twitter provides a Streaming API. By specifying keywords, a geographic locations or a set of user names, the API filters and returns all the matching data.
For more information on Twitter APIs see:
Flickr has set itself apart as the location for uploading, storing and sharing photos for everyone from families and hobbyists to professional photographers. Flickr provides feeds for public photos and videos, favorites, friends, discussions and more.
With the Photo Upload API, your app can upload photos synchronously or asynchronously using REST, SOAP and other protocols. API features include retrieving/posting blogs, getting camera information as well as retrieving/updating favorites, collections, contacts, groups, discussions and galleries.
For more on Flickr API’s, go to https://www.flickr.com/services/api/.
It didn’t take long for YouTube to become the go-to source for videos of every imaginable type. Google tried to create a competitor, but failed to make any headway, so they bought YouTube out-right. Now YouTube’s features are available through the Google Data API – a vast interface to a host of Google-provided services and data. YouTube features make it possible for your apps to search for videos and play them through your own site or app as well as retrieve standard feeds, like Popular and Trending. After authenticating, users of your app can upload videos, modify playlists and comment on / rate videos. We’ll be exploring some of these features in the ASP.NET MVC site you’ll create later in this article.
Google also provides a YouTube Analytics API for retrieving statistics, popularity metrics and demographics for videos and channels. There’s also a Live Streaming API for creating and managing live events on YouTube.
More Web API’s
The focus of this article is on social API’s. And there are numerous others including foursquare, LinkedIn, Tumbler and Google Plus.
But that’s only one variety of Web API. Others include,
- Mapping – Embed live maps on your site or in your app, request directions, get information about places (like restaurants or parks) in a region, retrieve street-level photos of a location and more. Examples: Google Maps APIs (https://developers.google.com/maps/) and Microsoft Bing Maps API (http://www.microsoft.com/maps/choose-your-bing-maps-API.aspx).
- Travel – Search for the flight, hotel and rental cars to meet specific needs, book your arrangements and manage trips. Examples: Yahoo Travel (http://developer.yahoo.com/travel/) and Concur (https://developer.concur.com/docs-and-resources/documentation)
- Music – Your apps can create, configure and listen to radio stations, retrieve album/artist/song information and share songs and playlists with others. Examples: Last.fm (http://www.last.fm/api) and MusicBrainz (http://wiki.musicbrainz.org/XMLWebService).
- Weather – Retrieve current conditions and forecasts, weather advisories, storm predictions and more for any place in the world. Examples: Weather Channel (http://www.wunderground.com/weather/api/) and NOAA National Weather Service (http://graphical.weather.gov/xml/).
- Even More – Sports, Marketing, Financial, Government, Search, Tools, Messaging, Science and Games – just a few more of the many categories of services available. For details, see http://www.programmableweb.com/category.