public static void ParsePage(int i) { var thumbnail = new PresentationsResource.PagesResource.GetThumbnailRequest(_slidesService, _presentationId, _pages[i].ObjectId); Thumbnail v = thumbnail.Execute(); string imageUrl = v.ContentUrl; System.Net.HttpWebRequest webRequest = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(imageUrl); webRequest.AllowWriteStreamBuffering = true; webRequest.Timeout = 30000; System.Net.WebResponse webResponse = webRequest.GetResponse(); System.IO.Stream streamI = webResponse.GetResponseStream(); SendStream(streamI); if (i == _pages.Count - 1) { Reset(); } }
public static void NewInstance(int lectureId) { _lectureId = lectureId; string lectureAdress = Const.PresentationAdresses[lectureId]; string stringId = lectureAdress.Split('/')[5]; UserCredential credential = null; try { using (var stream = new FileStream("credentials.json", FileMode.Open, FileAccess.Read)) { // The file token.json stores the user's access and refresh tokens, and is created // automatically when the authorization flow completes for the first time. string credPath = "token.json"; credential = GoogleWebAuthorizationBroker.AuthorizeAsync( GoogleClientSecrets.Load(stream).Secrets, Scopes, "user", CancellationToken.None, new FileDataStore(credPath, true)).Result; Console.WriteLine("Credential file saved to: " + credPath); } } catch (Exception ex) { } // Create Google Slides API service. var service = new SlidesService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = ApplicationName, }); _slidesService = service; // Define request parameters. _presentationId = stringId; PresentationsResource.GetRequest request = service.Presentations.Get(_presentationId); // Prints the number of slides and elements in a sample presentation: // https://docs.google.com/presentation/d/1EAYk18WDjIG-zp_0vLm3CsfQh_i8eXc67Jo2O9C6Vuc/edit Presentation presentation = request.Execute(); IList <Page> slides = presentation.Slides; _pages = slides; var thumbnail = new PresentationsResource.PagesResource.GetThumbnailRequest(service, _presentationId, slides[0].ObjectId); Thumbnail v = thumbnail.Execute(); string imageUrl = v.ContentUrl; System.Net.HttpWebRequest webRequest = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(imageUrl); webRequest.AllowWriteStreamBuffering = true; webRequest.Timeout = 30000; System.Net.WebResponse webResponse = webRequest.GetResponse(); System.IO.Stream streamI = webResponse.GetResponseStream(); SendStream(streamI); }