Skip to content

Instantly share code, notes, and snippets.

@kurozumi
Created December 4, 2020 06:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurozumi/c4fb71170ddbfc67e2edbaa0742f3753 to your computer and use it in GitHub Desktop.
Save kurozumi/c4fb71170ddbfc67e2edbaa0742f3753 to your computer and use it in GitHub Desktop.
ワードプレスの記事を取得する継承クラス
<?php
namespace Customize\Service\WordPress;
use GuzzleHttp\Client;
abstract class AbstractService
{
private $client;
public function __construct(Client $client)
{
$this->client = $client;
}
public function getPosts()
{
$response = $this->client->get("wp-json/wp/v2/posts");
return json_decode($response->getBody(), true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment