-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from ButterCMS/feature/api-changes
feat: Update due to API changes
- Loading branch information
Showing
6 changed files
with
194 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM php:8.2-cli | ||
|
||
WORKDIR /app | ||
COPY . . | ||
|
||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer | ||
RUN composer install | ||
|
||
ENV API_BASE_URL=https://api.buttercms.com/v2 | ||
ENV API_KEY=your_api_key | ||
|
||
CMD ["php", "demo/demo.php"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
require_once 'vendor/autoload.php'; | ||
|
||
use ButterCMS\ButterCMS; | ||
|
||
$apiKey = getenv('API_KEY'); | ||
if (empty($apiKey)) { | ||
die("API_KEY environment variable is not set\n"); | ||
} | ||
|
||
$client = new ButterCMS($apiKey); | ||
|
||
try { | ||
$params = ['preview' => 1]; | ||
$page = $client->fetchPage('*', 'test-page-1', $params); | ||
echo "Page Slug: " . $page->getSlug() . "\n"; | ||
echo "Page Status: " . $page->getStatus() . "\n"; | ||
echo "Page Scheduled Date: " . $page->getScheduled() . "\n"; | ||
} catch (Exception $e) { | ||
echo "Error fetching page: " . $e->getMessage() . "\n"; | ||
} | ||
|
||
try { | ||
$postResponse = $client->fetchPost('test-blog-post'); | ||
$post = $postResponse->getPost(); | ||
echo "Post Slug: " . $post->getSlug() . "\n"; | ||
echo "Post Status: " . $post->getStatus() . "\n"; | ||
echo "Post Scheduled Date: " . $post->getScheduled() . "\n"; | ||
} catch (Exception $e) { | ||
echo "Error fetching post: " . $e->getMessage() . "\n"; | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters