Ejemplo n.º 1
0
        protected override void OnViewInitialize(object sender, EventArgs e)
        {
            base.OnViewInitialize(sender, e);

            View.Username = "******";
            View.DOB      = null;

            View.SaveUser += View_SaveUser;


            string[] scopes = new string[] {
                PlusService.Scope.PlusLogin,
                PlusService.Scope.UserinfoEmail,
                PlusService.Scope.UserinfoProfile,
                PlusService.Scope.PlusMe
            };

            UserCredential userCredential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                new ClientSecrets
            {
                ClientId     = "463454622140-9g7bisaft6gt1imkfrufs3r1v0v6avgi.apps.googleusercontent.com",
                ClientSecret = "WPWGZkOvWk-VxoLNq7nySCHY"
            },
                scopes,
                Environment.UserName,
                CancellationToken.None,
                new FileDataStore("Current-See.GooglePlus.Auth.Store"))
                                            .Result;

            PlusService service = new PlusService(
                new BaseClientService.Initializer()
            {
                HttpClientInitializer = userCredential,
                ApplicationName       = "Current-See"
            });

            PeopleResource test = service.People;
        }
        /// <summary>
        /// List all of the people in the specified collection for a particular activity. 
        ///    The collection parameter specifies which people to list, such as people who have +1'd or reshared this activity. 
        /// Documentation: https://developers.google.com/+/api/latest/people/listByActivity
        /// </summary>
        /// <param name="service"></param>
        /// <param name="_activityId">The ID of the activity to get the list of people for.</param>
        /// <param name="_type">plusoners or resharers</param>
        /// <returns></returns>
        public static IList<Person> PeopleListByActivity(PlusService service, string _activityId , PeopleResource.ListByActivityRequest.CollectionEnum _type)
        {
            
            PeopleResource.ListByActivityRequest list = service.People.ListByActivity(_activityId,_type);
            list.MaxResults = 100;
            PeopleFeed peopleFeed = list.Execute();
            IList<Person> people = new List<Person>();

            //// Loop through until we arrive at an empty page
            while (peopleFeed.Items != null)
            {
                // Adding each item  to the list.
                foreach (Person item in peopleFeed.Items)
                {
                    people.Add(item);
                }

                // We will know we are on the last page when the next page token is
                // null.
                // If this is the case, break.
                if (peopleFeed.NextPageToken == null)
                {
                    break;
                }

                // Prepare the next page of results
                list.PageToken = peopleFeed.NextPageToken;

                // Execute and process the next page request
                peopleFeed = list.Execute();

            }

            return people;


        }