Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Ghost 5.0 route versioning #5

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

class Client
{
const ACCEPT_VERSION = 'v0.1';

/**
* Blog Base Uri
* @var string
Expand Down Expand Up @@ -68,7 +70,7 @@ public function initializeHTTPClient()
{
// Initialize the guzzle client
$this->httpClient = new \GuzzleHttp\Client([
'base_uri' => $this->baseUri . '/ghost/api/v0.1/'
'base_uri' => $this->baseUri . '/ghost/api/'
]);
}

Expand All @@ -89,6 +91,9 @@ public function isAuthenticated()
protected function authenticate()
{
$response = $this->httpClient->request('POST', 'authentication/token', [
'headers' => [
'Accept-Version' => self::ACCEPT_VERSION,
],
'form_params' => [
'grant_type' => 'password',
'username' => $this->username,
Expand Down Expand Up @@ -125,6 +130,7 @@ public function request($method, $route, $options)
// Here we prepare the guzzle request
$options['headers']['Authorization'] = 'Bearer ' . $this->getToken();
$options['headers']['Content-Type'] = 'application/json';
$options['headers']['Accept-Version'] = self::ACCEPT_VERSION;

// Do a guzzle request
return $this->httpClient->request($method, $route, $options);
Expand Down