public publicvideoinfo publicvideoinfos(string Email, string page)
{
String strPost = null;
StreamWriter myWriter = null;
HttpWebRequest objRequest;
if (page == null || page== "")
{
objRequest = (HttpWebRequest)WebRequest.Create("https://news-balloon-app.appspot.com/webservice/publicvideoinfo?email=" + Email + "&lat=30.3753&lng=69.3451&page=0&access_token=a131dd0bc5e646cc693d901d98aff95e");
}
else
{
objRequest = (HttpWebRequest)WebRequest.Create("https://news-balloon-app.appspot.com/webservice/publicvideoinfo?email=" + Email + "&lat=30.3753&lng=69.3451&page=" + page + "&access_token=a131dd0bc5e646cc693d901d98aff95e");
}
objRequest.Method = "GET";
objRequest.ContentType = "application/x-www-form-urlencoded";
//try
//{
// myWriter = new StreamWriter(objRequest.GetRequestStream());
// myWriter.Write(strPost);
//}
//catch (Exception ex)
//{
// throw ex;
//}
//finally
//{
// myWriter.Close();
//}
try
{
HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
{
var a = sr.ReadToEnd();
sr.Close();
string arr = "";
string array;
Container ss = new JavaScriptSerializer().Deserialize<Container>(a);
var jsonObject = Newtonsoft.Json.Linq.JObject.Parse(a);
List<value> value = new List<value>();
publicvideoinfo info = new publicvideoinfo();
foreach (var tmp in jsonObject)
{
if (tmp.Key == "reason")
{
info.reason = tmp.Value.ToString();
}
else if (tmp.Key == "result")
{
info.result = tmp.Value.ToString();
}
else if (tmp.Key == "success")
{
info.success = tmp.Value.ToString();
}
else if (tmp.Key == "total_pages")
{
info.total_pages = tmp.Value.ToString();
}
else if (tmp.Key == "total_videos")
{
info.total_videos = tmp.Value.ToString();
}
else if (tmp.Key == "value")
{
foreach (var item in tmp.Value)
{
Console.WriteLine(item);
Type type = item.GetType();
int flag;
string item2 = item.ToString();
if (int.TryParse(item2, out flag))
{ }
else
{
if (item2 != null)
{
value ss2 = new JavaScriptSerializer().Deserialize<value>(item2);
value.Add(ss2);
}
}
}
info.value = value;
}
}
return info;
}
}
catch (WebException webex)
{
WebResponse errResp = webex.Response;
using (Stream respStream = errResp.GetResponseStream())
{
StreamReader reader = new StreamReader(respStream);
string text = reader.ReadToEnd();
}
return null;
}
}
No comments:
Post a Comment