Ejemplo n.º 1
0
        //prints all the info collected from the API
        static void printInfo(FullContactPerson P)
        {
            Console.WriteLine("");
            Console.WriteLine("likelihood:");
            Console.WriteLine(P.likelihood);
            Console.WriteLine("");

            Console.WriteLine("Contact Info:");

            foreach (string infoString in P.contactInfo)
            {
                Console.WriteLine(infoString);
            }

            Console.WriteLine("");

            Console.WriteLine("Social Media:");

            foreach (string infoString in P.socialProfiles)
            {
                Console.WriteLine(infoString);
            }

            Console.WriteLine("");
        }
Ejemplo n.º 2
0
        private static async Task ProcessUserInput(string _user_input)
        {
            Console.WriteLine("Looking up user with email '" + _user_input + "'");
            try {
                FullContactPerson person = await GetPersonalInfoByEmail(_user_input);

                //We have to make sure data is fetched before we print
                Console.WriteLine(person);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Ejemplo n.º 3
0
        private static async Task <FullContactPerson> GetPersonalInfoByEmail(string _email)
        {
            if (IsValidEmail(_email))
            {
                FullContactAPI api = new FullContactAPI(Config.Instance.APIKey);

                FullContactPerson person = await api.LookupPersonByEmailAsync(_email);

                return(person);
            }
            else
            {
                throw new Exception("invalid email address");
            }
        }
Ejemplo n.º 4
0
        static async Task RunAsync(string emaillAddress)
        {
            try
            {
                Program p = new Program();
                // get person details
                FullContactPerson personDetails = await p.LookupPersonByEmailAsync(emaillAddress);

                // print details
                printFullContactPerson(personDetails);
            }

            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Ejemplo n.º 5
0
        public async Task <FullContactPerson> LookupPersonByEmailAsync(string email)
        {
            FullContactPerson personDetails = null;

            string url = "https://api.fullcontact.com/v2/person.json?email=" + email + "&apiKey=e0382def1e9359e9";

            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));


            HttpResponseMessage response = await client.GetAsync(url);

            if (response.IsSuccessStatusCode)
            {
                personDetails = await response.Content.ReadAsAsync <FullContactPerson>();
            }

            // return personDetails obj
            return(personDetails);
        }
Ejemplo n.º 6
0
        static async Task <int> MainAsync(string[] args)
        {
            bool ProgramRunning           = true;
            FullContactAPIClass yourClass = new FullContactAPIClass();

            while (ProgramRunning)
            {
                Console.WriteLine("skriv in en mail.");

                string input = Console.ReadLine();

                FullContactPerson FP = await yourClass.LookupPersonByEmailAsync(input);

                if (FP != null)
                {
                    printInfo(FP);
                }
            }

            return(1);
        }
Ejemplo n.º 7
0
        // print retrieved person details
        static void printFullContactPerson(FullContactPerson personDetails)
        {
            try
            {
                Console.WriteLine("********* Contact Info ********* ");

                // contact info

                ContactInfo _contactInfo;

                if (personDetails.contactInfo != null)
                {
                    _contactInfo = personDetails.contactInfo;

                    Console.WriteLine("---------------------");
                    Console.WriteLine("familyname: " + _contactInfo.familyName);
                    Console.WriteLine("full name: " + _contactInfo.fullName);
                    Console.WriteLine("given name: " + _contactInfo.givenName);
                    Console.WriteLine("---------------------");
                }
                else
                {
                    throw new Exception(" we could not find any information, try another email address");
                }

                // chats info
                if (_contactInfo.chats != null)
                {
                    if (_contactInfo.chats.Count > 0)
                    {
                        List <Chat> _chatInfo = _contactInfo.chats;
                        Console.WriteLine("*********  Chat Info ********* ");
                        for (int i = 0; i < _chatInfo.Count; i++)
                        {
                            Console.WriteLine("---------------------");
                            Console.WriteLine("client: " + _chatInfo[i].client);
                            Console.WriteLine("handle: " + _chatInfo[i].handle);
                            Console.WriteLine("---------------------");
                        }
                    }
                }

                // websites info
                if (_contactInfo.websites != null)
                {
                    if (_contactInfo.websites.Count > 0)
                    {
                        List <Website> _websiteInfo = _contactInfo.websites;

                        Console.WriteLine("*********  Website Info ********* ");
                        for (int i = 0; i < _websiteInfo.Count; i++)
                        {
                            Console.WriteLine("---------------------");
                            Console.WriteLine("url: " + _websiteInfo[i].url);
                            Console.WriteLine("---------------------");
                        }
                    }
                }


                if (personDetails.demographics != null)
                {
                    // demographic info
                    Demographic _demographiInfo = personDetails.demographics;
                    Console.WriteLine("*********  Demographic Info ********* ");
                    Console.WriteLine("---------------------");
                    Console.WriteLine("likelihood: " + _demographiInfo.likelihood.ToString());
                    Console.WriteLine("---------------------");
                }



                if (personDetails.socialProfiles != null)
                {
                    // social profiles info
                    if (personDetails.socialProfiles.Count > 0)
                    {
                        List <SocialProfile> _socialProfileInfo = personDetails.socialProfiles;

                        Console.WriteLine("*********  Social Profiles Info ********* ");
                        for (int i = 0; i < _socialProfileInfo.Count; i++)
                        {
                            Console.WriteLine("---------------------");
                            Console.WriteLine("username: "******"bio: " + _socialProfileInfo[i].bio);
                            Console.WriteLine("type: " + _socialProfileInfo[i].type);
                            Console.WriteLine("typeId: " + _socialProfileInfo[i].typeId);
                            Console.WriteLine("typeName: " + _socialProfileInfo[i].typeName);
                            Console.WriteLine("url: " + _socialProfileInfo[i].url);
                            Console.WriteLine("---------------------");
                        }
                    }
                }
            }

            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("---------------------");
            }
        }