public void CallWebPage(string url)
{
WebRequest request = WebRequest.Create(url);
//WebProxy proxy = new WebProxy("fresproxy1:8080");
//proxy.UseDefaultCredentials = true;
//request.Proxy = proxy;
request.Headers.Add("Key", Value);
request.Headers.Add("Key", Value);
WebResponse objWebResponse = request.GetResponse();
Stream objWebStream = objWebResponse.GetResponseStream();
string response = "";
string OAuthToken="";
using (StreamReader objStreamReader = new StreamReader(objWebStream))
{
response = objStreamReader.ReadToEnd();
}
//if response is json - deserialize that into dictionaries for easier operation - System.Web.Extensions.dll
JavaScriptSerializer desSSO = new JavaScriptSerializer();
IDictionary userInfo = desSSO.Deserialize<Dictionary<string, string>>(response);
foreach (DictionaryEntry entry in userInfo)
{
if (entry.Key.ToString() == "abc")
{
OAuthToken = entry.Value.ToString();
}
}
}
{
WebRequest request = WebRequest.Create(url);
//WebProxy proxy = new WebProxy("fresproxy1:8080");
//proxy.UseDefaultCredentials = true;
//request.Proxy = proxy;
request.Headers.Add("Key", Value);
request.Headers.Add("Key", Value);
WebResponse objWebResponse = request.GetResponse();
Stream objWebStream = objWebResponse.GetResponseStream();
string response = "";
string OAuthToken="";
using (StreamReader objStreamReader = new StreamReader(objWebStream))
{
response = objStreamReader.ReadToEnd();
}
//if response is json - deserialize that into dictionaries for easier operation - System.Web.Extensions.dll
JavaScriptSerializer desSSO = new JavaScriptSerializer();
IDictionary userInfo = desSSO.Deserialize<Dictionary<string, string>>(response);
foreach (DictionaryEntry entry in userInfo)
{
if (entry.Key.ToString() == "abc")
{
OAuthToken = entry.Value.ToString();
}
}
}
No comments:
Post a Comment