Hi all,
I am trying to display tweets from multiple users at the same time. I tried storing the urls in an array then looping through the array to get the urls and send them to " timeLineRequest = (HttpWebRequest)WebRequest.Create(urls);" but it only stores the last url. I am using a foreach for this. What am I doing wrong?
Coding in c#
Thanks in advance
Loading
Dhirendra MisraPosted Jan 9, 2014, 10:06 PM
Avuya MxoliPosted Jan 9, 2014, 6:21 AM
List
Avuya MxoliPosted Jan 9, 2014, 6:03 AM
Dhirendra MisraPosted Jan 9, 2014, 5:48 AM
Collection can be prepared using List<>
within foreach {}
List
timeLineResponse = (HttpWebResponse)timeLineRequest.GetResponse();
listTimeLineResponse.Add(timeLineResponse);
Avuya MxoliPosted Jan 9, 2014, 4:20 AM
I only get statuses for DebonairsPizza
Dhirendra MisraPosted Jan 9, 2014, 3:42 AM
I am not sure I am getting you properly. Are you getting value of variable "timeLineRequest" is as last URL because you are overwriting the value of variable "timeLineRequest" in the loop.
Hence the last URL value your are getting in variable when foreach exits.
I tried the same and I got output:
HttpWebRequest timeLineRequest;
string[] arrUrls = { "http://www.google.com", "http://www.contoso.com/default.html", "http://www.msn.com" };
foreach (string url in arrUrls)
{
timeLineRequest = (HttpWebRequest)WebRequest.Create(url);
Console.WriteLine(timeLineRequest.Host);
}
Output:
www.google.com
www.contoso.com
www.msn.com
Avuya MxoliPosted Jan 8, 2014, 1:30 AM
Dhirendra MisraPosted Jan 7, 2014, 11:37 PM
Please share the piece of code where you are storing the URLs in an array, I think there will be some issue.
Thanks