Exemple #1
0
        /*
         * return 0 : empty response
         * return 1 : got at least one profile
         * return 2 : request error
         * return 3 : no more profiles
         */
        public int GetPotentialMatches(List <TinderProfile> profiles)
        {
            string response;

            try
            {
                using (WebClient wc = new WebClient())
                {
                    wc.Headers[HttpRequestHeader.UserAgent] = "Tinder Android Version 4.3.1";
                    wc.Headers.Add("X-Auth-Token", auth_token);
                    wc.Headers.Add("os-version", "21");
                    wc.Headers.Add("app-version", "825");
                    wc.Headers.Add("platform", "android");
                    response = wc.DownloadString("https://api.gotinder.com/user/recs");
                }
            }
            catch
            {
                return(2);
            }

            //response = System.IO.File.ReadAllText(@"C:\Users\Thiago\Documents\Projetos Visual Studio\2015\Tinderino\json.txt");

            if (!string.IsNullOrWhiteSpace(response))
            {
                dynamic rj = JObject.Parse(response);
                if (rj.status == "200")
                {
                    foreach (dynamic r in rj.results)
                    {
                        TinderProfile tmpProfile = new TinderProfile();
                        tmpProfile.id       = r._id;
                        tmpProfile.distance = r.distance_mi;
                        tmpProfile.bio      = r.bio;
                        tmpProfile.name     = r.name;

                        string bd = r.birth_date;
                        bd = bd.Substring(6, 4);
                        int year = Int32.Parse(bd);
                        tmpProfile.age = 2015 - year;

                        foreach (dynamic p in r.photos)
                        {
                            string photoPath = p.processedFiles[0].url;
                            tmpProfile.photos.Add(photoPath);
                        }

                        tmpProfile.ConvertDistanceToKm();

                        profiles.Add(tmpProfile);
                    }
                    return(1);
                }
                else
                {
                    return(3);
                }
            }
            return(0);
        }
Exemple #2
0
        private void RefreshProfileView()
        {
            curPictureIndex          = 0;
            LikesRemainingLabel.Text = tinderAPI.likes_remaining.ToString();
            if (profiles.Count > 0)
            {
                LikeButton.Enabled            = true;
                PassButton.Enabled            = true;
                NextPictureButton.Enabled     = true;
                PreviousPictureButton.Enabled = true;

                TinderProfile tp = profiles.ElementAt(curProfileIndex);
                profilePicture.Load(tp.photos.First());

                string basicInfo = tp.name + " : " + tp.age + " : " + tp.distance + "km";
                NameLabel.Text = basicInfo;

                BioTextBox.Text = tp.bio;
            }
            else
            {
                LikeButton.Enabled            = false;
                PassButton.Enabled            = false;
                NextPictureButton.Enabled     = false;
                PreviousPictureButton.Enabled = false;
                BioTextBox.Text      = "Bio";
                profilePicture.Image = Tinderino.Properties.Resources.Koala;
                profilePicture.Refresh();
                NameLabel.Text = "No profile loaded";
            }
        }
Exemple #3
0
        /*
        * return 0 : empty response
        * return 1 : got at least one profile
        * return 2 : request error
        * return 3 : no more profiles
        */
        public int GetPotentialMatches(List<TinderProfile> profiles)
        {
            string response;

            try
            {
                using (WebClient wc = new WebClient())
                {
                    wc.Headers[HttpRequestHeader.UserAgent] = "Tinder Android Version 4.3.1";
                    wc.Headers.Add("X-Auth-Token", auth_token);
                    wc.Headers.Add("os-version", "21");
                    wc.Headers.Add("app-version", "825");
                    wc.Headers.Add("platform", "android");
                    response = wc.DownloadString("https://api.gotinder.com/user/recs");
                }
            }
            catch
            {
                return 2;
            }

            //response = System.IO.File.ReadAllText(@"C:\Users\Thiago\Documents\Projetos Visual Studio\2015\Tinderino\json.txt");

            if (!string.IsNullOrWhiteSpace(response))
            {
                dynamic rj = JObject.Parse(response);
                if (rj.status == "200")
                {
                    foreach(dynamic r in rj.results)
                    {
                        TinderProfile tmpProfile = new TinderProfile();
                        tmpProfile.id = r._id;
                        tmpProfile.distance = r.distance_mi;
                        tmpProfile.bio = r.bio;
                        tmpProfile.name = r.name;

                        string bd = r.birth_date;
                        bd = bd.Substring(6, 4);
                        int year = Int32.Parse(bd);
                        tmpProfile.age = 2015 - year;

                        foreach(dynamic p in r.photos)
                        {
                            string photoPath = p.processedFiles[0].url;
                            tmpProfile.photos.Add(photoPath);
                        }

                        tmpProfile.ConvertDistanceToKm();

                        profiles.Add(tmpProfile);
                    }
                        return 1;
                }
                else
                {
                    return 3;
                }
            }
            return 0;
        }