示例#1
0
        /// <summary>
        /// Checks in a movie through URL https://api.trakt.tv/movie/checkin/[KEY]
        /// </summary>
        /// <param name="IMDBID">The IMDBID of the movie.</param>
        /// <param name="title">The name of the movie. (Attribute is title on trakt.tv).</param>
        /// <param name="year">The year the movie premiered.</param>
        /// <returns>
        /// If the movie was successfully checked in on trakt.tv, it will return TRUE. If it
        /// fails FALSE will be returned.
        /// </returns>
        public async Task <Boolean> checkinMovie(String IMDBID, String title, Int16 year)
        {
            try
            {
                WebClient checkinClient     = new WebClient();
                String    assembly          = Assembly.GetExecutingAssembly().FullName;
                String    fullVersionNumber = assembly.Split('=')[1].Split(',')[0];

                CheckinAuth auth = new CheckinAuth();
                auth.imdb_id    = IMDBID;
                auth.Title      = title;
                auth.year       = year;
                auth.AppDate    = AppUser.getReleaseDate();
                auth.AppVersion = fullVersionNumber;

                String jsonString = await checkinClient.UploadStringTaskAsync(new Uri("https://api.trakt.tv/movie/checkin/9294cac7c27a4b97d3819690800aa2fedf0959fa"), AppUser.createJsonStringForAuthentication(typeof(CheckinAuth), auth));

                if (jsonString.Contains("failure"))
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (WebException)
            { GoogleAnalytics.EasyTracker.GetTracker().SendException("WebException in checkinMovie(" + IMDBID + ", " + title + ").", false); }
            catch (TargetInvocationException)
            { GoogleAnalytics.EasyTracker.GetTracker().SendException("TargetInvocationException in checkinMovie(" + IMDBID + ", " + title + ").", false); }
            return(false);
        }
示例#2
0
        private void CheckinMovie_Click(object sender, RoutedEventArgs e)
        {
            lastModel = (ListItemViewModel)((MenuItem)sender).DataContext;

            var checkinClient = new WebClient();

            checkinClient.UploadStringCompleted += new UploadStringCompletedEventHandler(checkinClient_UploadStringCompleted);
            CheckinAuth auth = new CheckinAuth();

            auth.imdb_id = lastModel.Imdb;
            auth.Title   = lastModel.Name;
            auth.year    = Int16.Parse(lastModel.SubItemText);
            auth.AppDate = AppUser.getReleaseDate();

            var assembly          = Assembly.GetExecutingAssembly().FullName;
            var fullVersionNumber = assembly.Split('=')[1].Split(',')[0];

            auth.AppVersion = fullVersionNumber;

            checkinClient.UploadStringAsync(new Uri("https://api.trakt.tv/movie/checkin/9294cac7c27a4b97d3819690800aa2fedf0959fa"), AppUser.createJsonStringForAuthentication(typeof(CheckinAuth), auth));
        }