Exemplo n.º 1
0
        public List <RedeSocialModel> getJsonTwitter(string userid)
        {
            List <RedeSocialModel> retornoPosts = new List <RedeSocialModel>();

            string strJson = Tweet.AuthTwitter(userid);

            if (!String.IsNullOrEmpty(strJson))
            {
                var retorno = JsonConvert.DeserializeObject <dynamic>(strJson);
                if (retorno.Count > 0)
                {
                    foreach (var item in retorno)
                    {
                        retornoPosts.Add(
                            new RedeSocialModel()
                        {
                            TipoRedeSocial = RedeSocialTipo.Twitter,
                            PostId         = item.id,
                            Mensagem       = item.text,
                            Picture        = item.entities.media != null ? item.entities.media[0].media_url_https : "",
                            Video          = "",
                            Link           = item.entities.media != null ? item.entities.media[0].url : "",
                            dataPublicacao = DateTime.ParseExact(item.created_at.ToString(), "ddd MMM dd HH:mm:ss zzzz yyyy", CultureInfo.InvariantCulture).ToString()
                        });
                    }
                }
            }

            return(retornoPosts.OrderByDescending(x => x.dataPublicacao).ToList());
        }