Skip to content

Commit

Permalink
Adding web API calls
Browse files Browse the repository at this point in the history
  • Loading branch information
apdutta committed Sep 23, 2015
1 parent 98e6052 commit dfbc4d1
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Lesson_203/FullSolution/MainPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Net.Http;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
Expand All @@ -26,6 +27,9 @@ public MainPage()
protected override async void OnNavigatedTo(NavigationEventArgs navArgs)
{
Debug.WriteLine("MainPage::OnNavigatedTo");

MakePinWebAPICall();

try
{
//Create a new object for our barometric sensor class
Expand Down Expand Up @@ -61,5 +65,21 @@ protected override async void OnNavigatedTo(NavigationEventArgs navArgs)
Debug.WriteLine(ex.Message);
}
}

/// <summary>
// This will put your pin on the world map of makers using this lesson.
// Microsoft will receive the IP address of your Raspberry Pi2
// this will be used to determine the rough geographic location of the device, in
// latitude and longitude. This information will be stored for use in generating the
// pin map showing the location of people who have also run this sample.
// This data will not be shared with any outside party.
/// </summary>
public void MakePinWebAPICall()
{
HttpClient client = new HttpClient();

// Comment this line to opt out of the pin map.
client.GetStringAsync("http://adafruitsample.azurewebsites.net/api?Lesson=203");
}
}
}
18 changes: 18 additions & 0 deletions Lesson_203/StartSolution/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public MainPage()
protected override async void OnNavigatedTo(NavigationEventArgs navArgs)
{
Debug.WriteLine("MainPage::OnNavigatedTo");

MakePinWebAPICall();
try
{
//Create a new object for our barometric sensor class
Expand All @@ -50,5 +52,21 @@ protected override async void OnNavigatedTo(NavigationEventArgs navArgs)
Debug.WriteLine(ex.Message);
}
}

/// <summary>
// This will put your pin on the world map of makers using this lesson.
// Microsoft will receive the IP address of your Raspberry Pi2
// this will be used to determine the rough geographic location of the device, in
// latitude and longitude. This information will be stored for use in generating the
// pin map showing the location of people who have also run this sample.
// This data will not be shared with any outside party.
/// </summary>
public void MakePinWebAPICall()
{
HttpClient client = new HttpClient();

// Comment this line to opt out of the pin map.
client.GetStringAsync("http://adafruitsample.azurewebsites.net/api?Lesson=203");
}
}
}
19 changes: 19 additions & 0 deletions Lesson_205/FullSolution/MainPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using System.Net.Http;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
using Windows.Devices.Gpio;
Expand Down Expand Up @@ -33,6 +34,8 @@ public MainPage()

protected override async void OnNavigatedTo(NavigationEventArgs navArgs)
{
MakePinWebAPICall();

try
{
//Create a new object for the color sensor class
Expand Down Expand Up @@ -97,6 +100,22 @@ private async Task SpeakColor(string colorRead)
audio.Play();
});
}

/// <summary>
// This will put your pin on the world map of makers using this lesson.
// Microsoft will receive the IP address of your Raspberry Pi2
// this will be used to determine the rough geographic location of the device, in
// latitude and longitude. This information will be stored for use in generating the
// pin map showing the location of people who have also run this sample.
// This data will not be shared with any outside party.
/// </summary>
public void MakePinWebAPICall()
{
HttpClient client = new HttpClient();

// Comment this line to opt out of the pin map.
client.GetStringAsync("http://adafruitsample.azurewebsites.net/api?Lesson=205");
}
}
}

18 changes: 18 additions & 0 deletions Lesson_205/StartSolution/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public MainPage()

protected override async void OnNavigatedTo(NavigationEventArgs navArgs)
{
MakePinWebAPICall();

try
{
//Create a new object for the color sensor class
Expand Down Expand Up @@ -98,6 +100,22 @@ private async Task SpeakColor(string colorRead)

});
}

/// <summary>
// This will put your pin on the world map of makers using this lesson.
// Microsoft will receive the IP address of your Raspberry Pi2
// this will be used to determine the rough geographic location of the device, in
// latitude and longitude. This information will be stored for use in generating the
// pin map showing the location of people who have also run this sample.
// This data will not be shared with any outside party.
/// </summary>
public void MakePinWebAPICall()
{
HttpClient client = new HttpClient();

// Comment this line to opt out of the pin map.
client.GetStringAsync("http://adafruitsample.azurewebsites.net/api?Lesson=205");
}
}
}

0 comments on commit dfbc4d1

Please sign in to comment.