-
Notifications
You must be signed in to change notification settings - Fork 0
/
GetSupporters.cs
30 lines (25 loc) · 901 Bytes
/
GetSupporters.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// This repository has example code for consuming the Buy me a coffee API
// first our needed usings
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
// Getting supporters
/// <summary>
/// Return a list of active Supporters as a model
/// </summary>
private async Task<string> GetSupportersAsync()
{
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("https://developers.buymeacoffee.com/");
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", access_token);
HttpResponseMessage response = await client.GetAsync("/api/v1/supporters");
if (response.IsSuccessStatusCode)
{
var data = await response.Content.ReadAsStringAsync();
return data;
}
return null;
}
//This line will give you a list of your supporters
var result = await GetSupportersAsync();