public ActionResult OAuthTest() { const string username = "******"; const string password = "******"; var accessToken = PearsonApiUtilities.GetOauthAccessToken(username, password); ViewBag.OAuthResult = accessToken; ViewBag.MeCoursesResult = PearsonApiUtilities.XAuthApiCall(accessToken, "http://m-api.ecollege.com/me/courses"); ViewBag.CourseDetails = PearsonApiUtilities.XAuthApiCall(accessToken, "https://m-api.ecollege.com/courses/3312999"); ViewBag.Students = PearsonApiUtilities.XAuthApiCall(accessToken, "https://m-api.ecollege.com/courses/3312999/students"); ViewBag.User = PearsonApiUtilities.XAuthApiCall(accessToken, "https://m-api.ecollege.com/users/4433390"); return(View()); }
public List <StudentCourses.Course> Student(string token, string id) { HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*"); var decodedToken = PearsonApiUtilities.DecodeFrom64(token); var meCoursesJson = PearsonApiUtilities.XAuthApiCall(decodedToken, "http://m-api.ecollege.com/me/courses"); var meCourses = new JavaScriptSerializer().Deserialize <MeCourses>(meCoursesJson); var result = new List <StudentCourses.Course>(); foreach (var course in meCourses.courses) { foreach (var link in course.links) { var courseDetailJson = PearsonApiUtilities.XAuthApiCall(decodedToken, link.href); var courseDetail = new JavaScriptSerializer().Deserialize <StudentCourses>(courseDetailJson); result.Add(courseDetail.courses[0]); } } return(result); }