What you get from the api in 'return answer_json;' as an index the name is a json text.
Json is a way to transform objects into text (to call it a rough way).
If you go to this page link and paste your text Json generates a series of classes like these:
public class UserMention
{
public string screen_name { get; set; }
public string name { get; set; }
public int id { get; set; }
public string id_str { get; set; }
public List<int> indices { get; set; }
}
public class Entities
{
public List<object> hashtags { get; set; }
public List<object> symbols { get; set; }
public List<UserMention> user_mentions { get; set; }
public List<object> urls { get; set; }
}
public class Description
{
public List<object> urls { get; set; }
}
public class Entities2
{
public Description description { get; set; }
}
public class User
{
public int id { get; set; }
public string id_str { get; set; }
public string name { get; set; }
public string screen_name { get; set; }
public string location { get; set; }
public string description { get; set; }
public object url { get; set; }
public Entities2 entities { get; set; }
public bool @protected { get; set; }
public int followers_count { get; set; }
public int friends_count { get; set; }
public int listed_count { get; set; }
public string created_at { get; set; }
public int favourites_count { get; set; }
public int utc_offset { get; set; }
public string time_zone { get; set; }
public bool geo_enabled { get; set; }
public bool verified { get; set; }
public int statuses_count { get; set; }
public string lang { get; set; }
public bool contributors_enabled { get; set; }
public bool is_translator { get; set; }
public bool is_translation_enabled { get; set; }
public string profile_background_color { get; set; }
public string profile_background_image_url { get; set; }
public string profile_background_image_url_https { get; set; }
public bool profile_background_tile { get; set; }
public string profile_image_url { get; set; }
public string profile_image_url_https { get; set; }
public string profile_banner_url { get; set; }
public string profile_link_color { get; set; }
public string profile_sidebar_border_color { get; set; }
public string profile_sidebar_fill_color { get; set; }
public string profile_text_color { get; set; }
public bool profile_use_background_image { get; set; }
public bool has_extended_profile { get; set; }
public bool default_profile { get; set; }
public bool default_profile_image { get; set; }
public object following { get; set; }
public object follow_request_sent { get; set; }
public object notifications { get; set; }
public string translator_type { get; set; }
}
public class Medium2
{
public int w { get; set; }
public int h { get; set; }
public string resize { get; set; }
}
public class Thumb
{
public int w { get; set; }
public int h { get; set; }
public string resize { get; set; }
}
public class Large
{
public int w { get; set; }
public int h { get; set; }
public string resize { get; set; }
}
public class Small
{
public int w { get; set; }
public int h { get; set; }
public string resize { get; set; }
}
public class Sizes
{
public Medium2 medium { get; set; }
public Thumb thumb { get; set; }
public Large large { get; set; }
public Small small { get; set; }
}
public class Medium
{
public long id { get; set; }
public string id_str { get; set; }
public List<int> indices { get; set; }
public string media_url { get; set; }
public string media_url_https { get; set; }
public string url { get; set; }
public string display_url { get; set; }
public string expanded_url { get; set; }
public string type { get; set; }
public Sizes sizes { get; set; }
}
public class Entities3
{
public List<object> hashtags { get; set; }
public List<object> symbols { get; set; }
public List<object> user_mentions { get; set; }
public List<object> urls { get; set; }
public List<Medium> media { get; set; }
}
public class Description2
{
public List<object> urls { get; set; }
}
public class Url2
{
public string url { get; set; }
public string expanded_url { get; set; }
public string display_url { get; set; }
public List<int> indices { get; set; }
}
public class Url
{
public List<Url2> urls { get; set; }
}
public class Entities4
{
public Description2 description { get; set; }
public Url url { get; set; }
}
public class User2
{
public int id { get; set; }
public string id_str { get; set; }
public string name { get; set; }
public string screen_name { get; set; }
public string location { get; set; }
public string description { get; set; }
public string url { get; set; }
public Entities4 entities { get; set; }
public bool @protected { get; set; }
public int followers_count { get; set; }
public int friends_count { get; set; }
public int listed_count { get; set; }
public string created_at { get; set; }
public int favourites_count { get; set; }
public int utc_offset { get; set; }
public string time_zone { get; set; }
public bool geo_enabled { get; set; }
public bool verified { get; set; }
public int statuses_count { get; set; }
public string lang { get; set; }
public bool contributors_enabled { get; set; }
public bool is_translator { get; set; }
public bool is_translation_enabled { get; set; }
public string profile_background_color { get; set; }
public string profile_background_image_url { get; set; }
public string profile_background_image_url_https { get; set; }
public bool profile_background_tile { get; set; }
public string profile_image_url { get; set; }
public string profile_image_url_https { get; set; }
public string profile_link_color { get; set; }
public string profile_sidebar_border_color { get; set; }
public string profile_sidebar_fill_color { get; set; }
public string profile_text_color { get; set; }
public bool profile_use_background_image { get; set; }
public bool has_extended_profile { get; set; }
public bool default_profile { get; set; }
public bool default_profile_image { get; set; }
public object following { get; set; }
public object follow_request_sent { get; set; }
public object notifications { get; set; }
public string translator_type { get; set; }
public string profile_banner_url { get; set; }
}
public class Hashtag
{
public string text { get; set; }
public List<int> indices { get; set; }
}
public class Url3
{
public string url { get; set; }
public string expanded_url { get; set; }
public string display_url { get; set; }
public List<int> indices { get; set; }
}
public class Entities5
{
public List<Hashtag> hashtags { get; set; }
public List<object> symbols { get; set; }
public List<object> user_mentions { get; set; }
public List<Url3> urls { get; set; }
}
public class Url5
{
public string url { get; set; }
public string expanded_url { get; set; }
public string display_url { get; set; }
public List<int> indices { get; set; }
}
public class Url4
{
public List<Url5> urls { get; set; }
}
public class Description3
{
public List<object> urls { get; set; }
}
public class Entities6
{
public Url4 url { get; set; }
public Description3 description { get; set; }
}
public class User3
{
public int id { get; set; }
public string id_str { get; set; }
public string name { get; set; }
public string screen_name { get; set; }
public string location { get; set; }
public string description { get; set; }
public string url { get; set; }
public Entities6 entities { get; set; }
public bool @protected { get; set; }
public int followers_count { get; set; }
public int friends_count { get; set; }
public int listed_count { get; set; }
public string created_at { get; set; }
public int favourites_count { get; set; }
public int utc_offset { get; set; }
public string time_zone { get; set; }
public bool geo_enabled { get; set; }
public bool verified { get; set; }
public int statuses_count { get; set; }
public string lang { get; set; }
public bool contributors_enabled { get; set; }
public bool is_translator { get; set; }
public bool is_translation_enabled { get; set; }
public string profile_background_color { get; set; }
public string profile_background_image_url { get; set; }
public string profile_background_image_url_https { get; set; }
public bool profile_background_tile { get; set; }
public string profile_image_url { get; set; }
public string profile_image_url_https { get; set; }
public string profile_banner_url { get; set; }
public string profile_link_color { get; set; }
public string profile_sidebar_border_color { get; set; }
public string profile_sidebar_fill_color { get; set; }
public string profile_text_color { get; set; }
public bool profile_use_background_image { get; set; }
public bool has_extended_profile { get; set; }
public bool default_profile { get; set; }
public bool default_profile_image { get; set; }
public object following { get; set; }
public object follow_request_sent { get; set; }
public object notifications { get; set; }
public string translator_type { get; set; }
}
public class QuotedStatus
{
public string created_at { get; set; }
public long id { get; set; }
public string id_str { get; set; }
public string text { get; set; }
public bool truncated { get; set; }
public Entities5 entities { get; set; }
public string source { get; set; }
public object in_reply_to_status_id { get; set; }
public object in_reply_to_status_id_str { get; set; }
public object in_reply_to_user_id { get; set; }
public object in_reply_to_user_id_str { get; set; }
public object in_reply_to_screen_name { get; set; }
public User3 user { get; set; }
public object geo { get; set; }
public object coordinates { get; set; }
public object place { get; set; }
public object contributors { get; set; }
public bool is_quote_status { get; set; }
public int retweet_count { get; set; }
public int favorite_count { get; set; }
public bool favorited { get; set; }
public bool retweeted { get; set; }
public bool possibly_sensitive { get; set; }
public string lang { get; set; }
}
public class Medium4
{
public int w { get; set; }
public int h { get; set; }
public string resize { get; set; }
}
public class Thumb2
{
public int w { get; set; }
public int h { get; set; }
public string resize { get; set; }
}
public class Large2
{
public int w { get; set; }
public int h { get; set; }
public string resize { get; set; }
}
public class Small2
{
public int w { get; set; }
public int h { get; set; }
public string resize { get; set; }
}
public class Sizes2
{
public Medium4 medium { get; set; }
public Thumb2 thumb { get; set; }
public Large2 large { get; set; }
public Small2 small { get; set; }
}
public class Medium3
{
public object id { get; set; }
public string id_str { get; set; }
public List<int> indices { get; set; }
public string media_url { get; set; }
public string media_url_https { get; set; }
public string url { get; set; }
public string display_url { get; set; }
public string expanded_url { get; set; }
public string type { get; set; }
public Sizes2 sizes { get; set; }
}
public class ExtendedEntities
{
public List<Medium3> media { get; set; }
}
public class RetweetedStatus
{
public string created_at { get; set; }
public object id { get; set; }
public string id_str { get; set; }
public string text { get; set; }
public bool truncated { get; set; }
public Entities3 entities { get; set; }
public string source { get; set; }
public object in_reply_to_status_id { get; set; }
public object in_reply_to_status_id_str { get; set; }
public object in_reply_to_user_id { get; set; }
public object in_reply_to_user_id_str { get; set; }
public object in_reply_to_screen_name { get; set; }
public User2 user { get; set; }
public object geo { get; set; }
public object coordinates { get; set; }
public object place { get; set; }
public object contributors { get; set; }
public bool is_quote_status { get; set; }
public long quoted_status_id { get; set; }
public string quoted_status_id_str { get; set; }
public QuotedStatus quoted_status { get; set; }
public int retweet_count { get; set; }
public int favorite_count { get; set; }
public bool favorited { get; set; }
public bool retweeted { get; set; }
public bool possibly_sensitive { get; set; }
public string lang { get; set; }
public ExtendedEntities extended_entities { get; set; }
}
public class Tweet
{
public string created_at { get; set; }
public object id { get; set; }
public string id_str { get; set; }
public string text { get; set; }
public bool truncated { get; set; }
public Entities entities { get; set; }
public string source { get; set; }
public long? in_reply_to_status_id { get; set; }
public string in_reply_to_status_id_str { get; set; }
public int? in_reply_to_user_id { get; set; }
public string in_reply_to_user_id_str { get; set; }
public string in_reply_to_screen_name { get; set; }
public User user { get; set; }
public object geo { get; set; }
public object coordinates { get; set; }
public object place { get; set; }
public object contributors { get; set; }
public bool is_quote_status { get; set; }
public int retweet_count { get; set; }
public int favorite_count { get; set; }
public bool favorited { get; set; }
public bool retweeted { get; set; }
public string lang { get; set; }
public RetweetedStatus retweeted_status { get; set; }
public long? quoted_status_id { get; set; }
public string quoted_status_id_str { get; set; }
public bool? possibly_sensitive { get; set; }
}
If with what the function returns you do something like:
JavaScriptSerializer serializer = new JavaScriptSerializer();
List<Tweet> item = serializer.Deserialize<List<Tweet>>(clase.button_go_Clic());
Where what you are doing is deconverting the Json, in a list of Tweet objects with the properties the properties and objects that have the content of the tweet, and there you already have the texts legibly.
To show the text and the date, it is enough to call item [0] .created_at (the date) and item [0] .text of the first element, for example.
EDIT: EXPLANATIONS FOOTSTEPS
What you had above is already real evidence that I did, but I detail it more (sorry if I step).
First copy the long part of my code, they are the main class, and all the secondary classes that are generated with the information that comes from the tweets, put it in a new class that is called for example Tweet (you create the class, and you erase what is less the namespace and copies that).
Then you go to the project, you give it to administer nuget packages (right button on top of the project) and on the left tab (Browse) you search for Newton, you will get one that is Newtonsoft.Json and you give it to install.
Now you have the class structure to transform the json text into usable classes by c # and the api that will take care of it.
Of the code that you put in I understand that you have a button that "calls" the twitter api and brings the post, but I do not understand what you want to do with them.
I would advise you not to return the method, but to fill in a global variable, but well, following your example, your function should look like this:
public List<Tweet> button_go_Clic()
{
string consumer_key = ""; // Mi consumer Key
string consumer_secret = ""; //Mi consumer secret
//Obtenemos el acess_token que es lo que nos autentifica
string access_token = GetAccessToken(consumer_key, consumer_secret);
//Obtenemos el código JSON de respuesta del Timeline
string usuario = "MiUsuario";
string timeline_json = GetTimeline(access_token, usuario);
List<Tweet> listado = JsonConvert.DeserializeObject<Tweet>(timeline_json);
return listado;
}
That way you ask for the timeline to the twitter api, you get a json, you turn it into a list of objects with Newtonsoft's api (what I put before Javascriptserialize is the one that carries the system itself, but the of newton is faster) and already with that list you do what you want.
In my opinion you should avoid creating variables just to use them below, and you could simplify the last 3 lines of your function like this:
return JsonConvert.DeserializeObject<Tweet>(GetTimeline(access_token, usuario));
But I guess it's less clear, and a little bit of taste.