1. Go to this page and download the library: Download joeymckenzie/givebutter-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
joeymckenzie / givebutter-php example snippets
/** @var string $apiKey */
$apiKey = $_ENV['GIVEBUTTER_API_KEY'];
$client = Givebutter::client($apiKey);
// Create a campaign
$createdCampaign = $client
->campaigns()
->create([
'description' => 'This is a test campaign.',
'end_at' => CarbonImmutable::now()->toIso8601String(),
'goal' => 1000,
'subtitle' => 'subtitle',
'slug' => md5(uniqid('', true)),
'title' => 'title',
'type' => 'collect',
]);
var_dump($createdCampaign);
// Get a campaign
$campaign = $client
->campaigns()
->get(441507);
var_dump($campaign);
// Get all campaigns
$campaigns = $client
->campaigns()
->list();
var_dump($campaigns);
// Update a campaign
$updatedCampaign = $client
->campaigns()
->update($campaign->id, [
'description' => 'This is a test campaign.',
'goal' => 1500,
]);
var_dump($updatedCampaign);
// Delete a campaign
$deleteResponse = $client
->campaigns()
->delete($campaign->id);
var_dump($deleteResponse);