Integrate Social Media Features: Getting Started with the Fan Project
Getting Started with the Visual Studio Fan Project
Now that you know what’s out there, it’s time to see what Visual Studio can do to make your Web API interfacing quick and painless!
The project you’ll create here is an unofficial Visual Studio Fan site. For this site, you want to search for all the latest videos related to Visual Studio and make them available in one place. Then you’ll allow them to click on any of the video links to see them on a page you create. This keeps them on the site rather than having them wander off to YouTube and forgetting about Visual Studio Fan!
The Basic Requirements
I’ll assume you have Visual Studio Community Edition installed. If not, see “Getting a Free, Yet Powerful Web Dev Tool: Visual Studio Community 2015 Edition”. I’m also assuming that you know the basics of developing with ASP.NET MVC. If not, check out these resources:
However the techniques described in this article are not specific to ASP.NET MVC. You can use them to interface with Web API’s when creating mobile applications, desktop applications and nearly any other kind of application available from Visual Studio.
Registering with the Provider
The first step to using virtually any Web API is registering with the provider of it. This is necessary because they want to know who’s using their services and how much they use it. Some providers may have limits on the number of requests that they’ll accept per day/week/month. However these limits are usually very high and would likely only affect you if your application was wildly more successful than you dream! And if that happens you’ll probably be able to afford a reasonable fee to the provider.
For YouTube, the first step is to create a Google login. You probably already have one. But if you want to make a separate one for your app development work, you should do that first.
Next log in using the account and go to Google’s API Console:
Click Create project…
On the Developers Console page, with APIs selected on the left, scroll down to the YouTube APIs and click YouTube Data API.
Now simply click Enable API.
You can click Usage on this page to find out about those upper limits I mentioned. You can also click Learn more for articles or Explore this API for documentation.
For now, on the left under APIs, click Credentials.
For this application, you simply want to do a general search. You don’t need the user to log in or to access the user’s favorites, etc. So OAuth would be overkill. Instead, click Create new Key for public access.
Now a dialog prompts you to find out what kind of application you’re creating.
Since it will be a web site, click Server key. Now you are asked if you’d like to restrict this project so that only requests from certain IP’s are accepted. You don’t need that now, so leave it blank and click Create.
Now you have what you need – an API key. You’ll use this in your code a little later.