Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame
Instagram is a nifty little app that allows you to share photos on social media. There is one caveat with Instagram, though; it is available solely on a mobile platform. Today, I will show you how to create a little Instagram app with Visual Basic.
As stated throughout my social media article series this month, you cannot directly start coding. To write an app that makes use of Instagram's API, you first need to create a developer's account with them. Naturally, I had to first download Instagram on my Android device. By downloading Instagram, you needed to supply an email address. This address is crucial when you want to create a developer's account.
Figure 1: Instagram developer details
There are a few Instagram SDKs and wrappers floating around. Here is a short list of the most popular ones:
Today's little project will show you how to make use of the Instasharp wrapper for Instagram and how to read certain feeds. Nothing too overly complicated.
Create a new Windows Store project with VB and add two listboxes to your page. Name these anything you like. If you haven't downloaded the Instasharp wrapper yet, I suggest you do so now before continuing. After you have downloaded the wrapper, add a reference to it by clicking Project, Add reference, Navigate to the libraries location and selected it, as shown in Figure 2.
Figure 2: Instasharp Reference
Not much code, honestly, because this is just an example to get you started on your way.
Add the namespaces:
Imports InstaSharp Imports NewtonSoft.JSon
Add the modular variables:
Dim config = New InstaSharp.InstagramConfig("https://api.instagram.com/v1", "https://api.instagram.com/oauth", "693103ec45c44c40be1690f675765def", "c832ed3dd0a048ec87ec68c712d14237", "http://localhost:80") Dim oauth = New OAuth(config) Dim link = oauth.AuthLink(config, scopes, oauth.ResponseType.Code) Dim authInfo = Await oauth.RequestToken("693103ec45c44c40be1690f675765def") Dim tagsApi = New InstaSharp.Endpoints.Tags(config, authInfo) Dim tagInfo = tagsApi.Get("tagName")
The first object, config, allows you to get access to Instagram's functionalities, because of the way the Instasharp DLL works. You have to supply the location of the Instagram API, where to get the Authorizing information, your app's key, and your app's secret. Secondly, you instantiate the OAuth object. The rest of the objects just ensure that you may use the Instagram API in your application.
Add the last piece of the puzzle:
Public Sub GetFeed() Dim userlist1 = New List(Of InstaSharp.Models.User) Dim userlist2 = New List(Of InstaSharp.Models.User) Dim Media = New List(Of InstaSharp.Models.Media) Dim users As InstaSharp.Endpoints.Users(config) Dim result = users.Feed("self") userlist1 = result.Result.Data lstList1.Items.Add(userlist1) Dim result2 = users.Search("beyonce") userlist2 = result.Result.Data lstList2.Items.Add(userlist2) End Sub Private Sub MainPage_Loaded(sender As Object, _ e As RoutedEventArgs) Handles Me.Loaded GetFeed() End Sub
This sub creates two generic lists. The first list contains my feed, whereas the second list shows the feed from "beyonce" inside listboxes.
Thank you for reading.