public async Task GetHostedStreams(int p_offset)
        {
            UserFollows userFollows = await GetFollowedAsync(p_offset);

            foreach (UserFollow userFollow in userFollows.Follows)
            {
                double uid = userFollow.Channel.Id;
                GetHost(uid);
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            List <int> lis = new List <int>()
            {
                0, 1, 12, 456561615, 4444
            };
            var str = UserFollows.Encode(lis);
            int a   = 0;
            var t   = UserFollows.Decode(str);

            a = 0;
        }
예제 #3
0
        /******************************************************** GETTERS *********************************************************/

        /// <summary>
        ///     <para>gets the list of users that a user follows</para>
        /// </summary>
        /// <param name="UserId"></param>
        /// <param name="Parameters"></param>
        /// <returns></returns>
        public UserFollows GetUserFollows(String UserId, GetUserFollowsParameters Parameters)
        {
            UserFollows Follows = null;

            try
            {
                // SET UP REQUEST URI
                UriBuilder BaseUri = new UriBuilder();

                BaseUri.Scheme = Config.GetUriScheme();
                BaseUri.Host   = Config.GetApiUriString();
                BaseUri.Path   = "users/" + UserId + "/follows";

                // SET UP QUERY String
                NameValueCollection QueryString = System.Web.HttpUtility.ParseQueryString(String.Empty);
                QueryString.Add("access_token", AuthorisedUser.AccessToken);
                QueryString.Add("count", Parameters.Count.ToString());
                QueryString.Add("cursor", Parameters.NextCursor);

                // SET THE QUERY StringS
                BaseUri.Query = QueryString.ToString();

                // CREATE NEW USER FOLLOWS OBJECT
                Follows = new UserFollows();

                // SEND REQUEST
                WebClient Client       = new WebClient();
                byte[]    ResponseData = Client.DownloadData(BaseUri.Uri);
                String    Response     = Encoding.UTF8.GetString(ResponseData);

                // PARSE JSON
                dynamic ParsedJson = JsonConvert.DeserializeObject(Response);

                // CREATE META OBJECT
                MetaData Meta = new MetaData();
                Meta.Code    = ParsedJson.meta.code;
                Follows.Meta = Meta;

                // CREATE PAGINATION OBJECT
                PaginationCursorData Pagination = new PaginationCursorData();
                Pagination.NextUrl    = ParsedJson.pagination.next_url;
                Pagination.NextCursor = ParsedJson.pagination.next_cursor;
                Follows.Pagination    = Pagination;

                // CREATE DATA LIST
                List <User> Data = new List <User>();
                foreach (dynamic EachUser in ParsedJson.data)
                {
                    // CREATE AND FILL USER OBJECT
                    User User = new User();
                    User.UserName       = EachUser.username;
                    User.Bio            = EachUser.bio;
                    User.Website        = EachUser.website;
                    User.ProfilePicture = EachUser.profile_picture;
                    User.FullName       = EachUser.full_name;
                    User.Id             = EachUser.id;

                    // ADD USER TO THE LIST
                    Data.Add(User);
                }
                Follows.Data = Data;
            }
            catch (WebException WEx)
            {
                // FETCHES ANY ERROR THROWN BY INSTAGRAM API
                Stream ResponseStream = WEx.Response.GetResponseStream();
                if (ResponseStream != null)
                {
                    StreamReader ResponseReader = new StreamReader(ResponseStream);
                    if (ResponseReader != null)
                    {
                        // PARSE JSON
                        dynamic ParsedJson = JsonConvert.DeserializeObject(ResponseReader.ReadToEnd());

                        // CREATE NEW META OBJECT AND FILL IN DATA
                        MetaData Meta = new MetaData();
                        Meta.Code         = ParsedJson.meta.code;
                        Meta.ErrorType    = ParsedJson.meta.error_type;
                        Meta.ErrorMessage = ParsedJson.meta.error_message;
                        Follows.Meta      = Meta;
                    }
                }
            }
            catch (Exception Ex)
            {
                Console.WriteLine(Ex.StackTrace);
            }

            return(Follows);
        }
        public async static Task <int> GetTotalFollowed()
        {
            UserFollows follows = await TwitchClient.GetUserFollowsAsyncV5();

            return(follows.Total);
        }
        private async Task <UserFollows> GetFollowedAsync(int p_offset)
        {
            UserFollows uf = await TwitchClient.GetUserFollowsAsyncV5(PageSize, (p_offset - 1) *PageSize);

            return(uf);
        }