コード例 #1
0
        public HttpResponseMessage Get(string playlistId, string pageToken = "")
        {
            if (!RequestProtection.AddRequest(WebApiApplication.GetClientIp(), RequestType.PlaylistRequest))
            {
                return(Request.CreateResponse(HttpStatusCode.Forbidden, "Usage limit exceeded"));
            }
            try
            {
                var client  = new RestClient("https://www.googleapis.com");
                var request = new RestRequest("/youtube/v3/playlistItems", Method.GET);

                request.AddParameter("key", Properties.Settings.GoogleApiKey);
                request.AddParameter("part", "snippet");
                request.AddParameter("playlistId", playlistId);
                request.AddParameter("maxResults", 50);
                request.AddParameter("pageToken", pageToken);

                var response = client.Execute(request);

                return(Request.CreateResponse(response.StatusCode, JObject.Parse(response.Content)));
            }
            catch
            {
                // ignored
            }

            return(Request.CreateResponse(HttpStatusCode.InternalServerError));
        }
コード例 #2
0
        public async Task <HttpResponseMessage> Post([FromBody] CrashReport report)
        {
            var ip = WebApiApplication.GetClientIp();

            if (!RequestProtection.AddRequest(ip, RequestType.CrashReport))
            {
                return(Request.CreateResponse(HttpStatusCode.Forbidden, "Usage limit exceeded"));
            }

            var issueId = await GitHubReporter.CreateIssue(ip, report);

            return(MailReporter.SendMail(ip, report, issueId) ? Request.CreateResponse(HttpStatusCode.OK, "Success") : Request.CreateResponse(HttpStatusCode.InternalServerError, "Error sending message"));
        }
コード例 #3
0
        public HttpResponseMessage Get(string name)
        {
            var ip = WebApiApplication.GetClientIp();

            if (!RequestProtection.AddRequest(ip, RequestType.TrackInfoRequest))
            {
                return(Request.CreateResponse(HttpStatusCode.Forbidden, "Usage limit exceeded"));
            }

            try
            {
                return(Request.CreateResponse(TrackInformationFetcher.GetTrackInformation(name)));
            }
            catch
            {
                // ignored
            }

            return(Request.CreateResponse(HttpStatusCode.InternalServerError));
        }