Skip to content

Commit 6525005

Browse files
committed
Update LocationSample
1 parent 7ae8357 commit 6525005

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System;
2+
using System.Linq;
3+
using System.Threading.Tasks;
4+
using InstagramApiSharp;
5+
using InstagramApiSharp.API;
6+
using InstagramApiSharp.Classes;
7+
/////////////////////////////////////////////////////////////////////
8+
////////////////////// IMPORTANT NOTE ///////////////////////////////
9+
// Please check wiki pages for more information:
10+
// https://github.com/ramtinak/InstagramApiSharp/wiki
11+
////////////////////// IMPORTANT NOTE ///////////////////////////////
12+
/////////////////////////////////////////////////////////////////////
13+
namespace Examples.Samples
14+
{
15+
internal class LocationSample : IDemoSample
16+
{
17+
private readonly IInstaApi InstaApi;
18+
19+
public LocationSample(IInstaApi instaApi)
20+
{
21+
InstaApi = instaApi;
22+
}
23+
24+
public async Task DoShow()
25+
{
26+
// search for related locations near location with latitude = 55.753923, logitude = 37.620940
27+
// additionaly you can specify search query or just empty string
28+
var result = await InstaApi.LocationProcessor.SearchLocationAsync(55.753923, 37.620940, "square");
29+
Console.WriteLine($"Loaded {result.Value.Count} locations");
30+
var firstLocation = result.Value?.FirstOrDefault();
31+
if(firstLocation == null)
32+
return;
33+
Console.WriteLine($"Loading feed for location: name={firstLocation.Name}; id={firstLocation.ExternalId}.");
34+
35+
var locationStories =
36+
await InstaApi.LocationProcessor.GetLocationStoriesAsync(long.Parse(firstLocation.ExternalId));
37+
38+
Console.WriteLine(locationStories.Succeeded
39+
? $"Loaded {locationStories.Value.Items?.Count} stoires for location"
40+
: $"Unable to load location '{firstLocation.Name}' stories");
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)