-
Notifications
You must be signed in to change notification settings - Fork 0
/
GetExtras.cs
35 lines (29 loc) · 1.07 KB
/
GetExtras.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
31
32
33
34
35
// 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 active members
// First you need to setup your ACCESS_TOKEN
// Go here and login to get your token
// https://developers.buymeacoffee.com/dashboard
private static string access_token = "change me to your token!";
/// <summary>
/// Return a list of extra transactions as a model
/// </summary>
private async Task<string> GetExtrasAsync()
{
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/extras");
if (response.IsSuccessStatusCode)
{
var data = await response.Content.ReadAsStringAsync();
return data;
}
return null;
}
//This line will give you a list of your extra packs
var result = await GetExtrasAsync();