Exemplo n.º 1
0
        public void Send(string accessToken, Note note)
        {
            var data = new List<KeyValuePair<string, string>>
                {
                    new KeyValuePair<string, string>("title", note.Title),
                    new KeyValuePair<string, string>("body", note.Body),
                    new KeyValuePair<string, string>("type", "note")
                };

            var encodedToken = Convert.ToBase64String(Encoding.UTF8.GetBytes(accessToken));
            var uri = new Uri(ApiUri, "pushes");

            var request = new HttpRequestMessage(HttpMethod.Post, uri)
            {
                Content = new FormUrlEncodedContent(data)
            };

            request.Headers.Add("Authorization", "Basic " + encodedToken);

            var response = _httpClient.SendAsync(request).Result;

            if (!response.IsSuccessStatusCode)
            {
                _logger.Error("Error pushing message. Response status code: {StatusCode}.", response.StatusCode);
            }
        }
Exemplo n.º 2
0
 public void TestConfig(PushbulletConfig config)
 {
     var note = new Note("Hadouken", "Test notification from Hadouken.");
     _pushbulletClient.Send(config.AccessToken, note);
 }