Hello how can i show my active patron names on my wordpress site.
i use this code but i am getting error because of campaign id
function display_patreon_supporters() {
// Retrieve the Patreon API access token
$access_token = ‘TOKEN’;
// Set up the API request
$api_url = 'https://www.patreon.com/api/oauth2/v2/campaigns/CAMPAIGN_ID/members';
$headers = array(
'Authorization' => 'Bearer ' . $access_token,
);
// Make the API request
$response = wp_remote_get($api_url, array('headers' => $headers));
// Check if the request was successful
if (!is_wp_error($response) && $response['response']['code'] === 200) {
$body = json_decode($response['body'], true);
// Retrieve the list of patrons/supporters
$supporters = $body['data'];
if (!empty($supporters)) {
// Display the supporter names
echo '<ul>';
foreach ($supporters as $supporter) {
echo '<li>' . $supporter['attributes']['full_name'] . '</li>';
}
echo '</ul>';
} else {
echo 'No supporters found.';
}
} else {
echo 'Failed to retrieve supporters.';
}
}
add_shortcode(‘patreon_supporters’, ‘display_patreon_supporters’);
thank you