public ActionResult GetPositions(int clientId, DateTime endDate) { var domain = clientRepository.Where(c => c.Id == clientId).Select(c => c.Domain).SingleOrDefault(); if (string.IsNullOrEmpty(domain)) { Response.StatusCode = 404; return(Content("Could not find domain data for client.", "application/json")); } var rakings = serpRankingRepository.GetRankings(domain, endDate); return(Content(jsonConverter.Serilize(rakings), "application/json")); }
public string GetShortUrl(string longUrl) { WebRequest request = WebRequest.Create("https://www.googleapis.com/urlshortener/v1/url?key=" + googleApiKey); request.Method = "POST"; request.ContentType = "application/json"; var jsonData = jsonCoverter.Serilize(new GoogleUrlShortnerMessage { longUrl = longUrl }); string requestData = jsonData; byte[] requestRawData = Encoding.ASCII.GetBytes(requestData); request.ContentLength = requestRawData.Length; Stream requestStream = request.GetRequestStream(); requestStream.Write(requestRawData, 0, requestRawData.Length); requestStream.Close(); WebResponse response = request.GetResponse(); StreamReader responseReader = new StreamReader(response.GetResponseStream()); string responseData = responseReader.ReadToEnd(); responseReader.Close(); var shortnerResult = jsonCoverter.Deserilize <GoogleUrlShortnerResponse>(responseData); return(shortnerResult.id); }
// Post: GoogleApi public ActionResult GetToken(string code) { var refreshToken = googleAuthentication.GetRefreshToken(code, "http://inside.helloy.se/GoogleApi/CodeCallback"); return(Content(jsonConverter.Serilize(refreshToken))); }