private static ILocation GetLocationInfo(Clipping Clipping, string Line) { var pageNumber = new PageNumber(Clipping, Line); if (pageNumber.IsMatch) { return(pageNumber); } var location = new Location(Clipping, Line); if (location.IsMatch) { return(location); } var locationShort = new LocationShort(Clipping, Line); if (locationShort.IsMatch) { return(locationShort); } throw new Exception("Location portion of line did not match a known location type."); }
public static string GetJson(this LocationShort location) { if (location == null) { return(null); } return(new JObject { { "name", location.Address ?? string.Empty }, { "address", location.ExternalId ?? string.Empty }, { "lat", location.Lat }, { "lng", location.Lng }, { "external_source", location.ExternalSource ?? "facebook_places" }, { "facebook_places_id", location.ExternalId } }.ToString(Formatting.None)); }
private async Task <IResult <InstaMedia> > UploadImage(string image, string caption, LocationShort location) { if (location != null) { log.LogInformation("Searching similar locations [{0}]", location.Name); var similarLocations = await instagram.LocationProcessor.SearchLocationAsync(location.Lat, location.Lng, location.Name).ConfigureAwait(false); if (similarLocations.Succeeded) { location = similarLocations.Value.FirstOrDefault(); log.LogInformation("Selected location : [{0}]", location?.Name); } } log.LogInformation("Uploading Image..."); var imageData = new ImageUpload { // leave zero, if you don't know how height and width is it. Height = 0, Width = 0, Uri = image, }; return(await instagram.MediaProcessor.UploadPhotoAsync(imageData, caption, location).ConfigureAwait(false)); }