-
Notifications
You must be signed in to change notification settings - Fork 0
/
GetOneMemberById.cs
35 lines (29 loc) · 1.1 KB
/
GetOneMemberById.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 a member by id
// 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 single Members by id as a member model
/// </summary>
private async Task<string> GetMemberAsync(int id)
{
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/subscriptions/{id}");
if (response.IsSuccessStatusCode)
{
var data = await response.Content.ReadAsStringAsync();
return data;
}
return null;
}
//This line will give you the details of one of your members
var result = await GetMemberAsync(id);