dev-master
9999999-devPHP package for interacting with the Defaqto.io API.
The Requires
- php >=5.3.0
- guzzle/guzzle ~3.7
by Billy Jones
PHP package for interacting with the Defaqto.io API.
DefaqtoIO PHP Client is a PHP package for using the DefaqtoIO CMS service., (*1)
Add the library to your composer.json file, (*2)
"theninthnode/defaqto": "dev-master"
Run composer install
to get the latest version of the package., (*3)
It's recommended that you use Composer, however you can download and install from this repository., (*4)
Please note. This client requires the Guzzle REST PHP package., (*5)
This package comes with a Service Provider and Facade for easy integration with Laravel4., (*6)
Add the following entry to the providers
array in config/app.php, (*7)
'TheNinthNode\Defaqto\DefaqtoServiceProvider', (*8)
Add the following entry to the aliases
array in config/app.php, (*9)
'Defaqto' => 'TheNinthNode\Defaqto\Facades\Defaqto',, (*10)
After installing the package you can use it like this:, (*11)
$pages = Defaqto::setup($app_id, $access_token)->get('pages'); var_dump($pages);
NOTE. If you get a class not found error load the class in with:, (*12)
use TheNinthNode\Defaqto\Defaqto;
OR, (*13)
$pages = TheNinthNode\Defaqto\Defaqto::setup($app_id, $access_token)->get('pages');
You can use the class with the following syntax:, (*14)
$html = Defaqto::setup($app_id, $access_token)->get('resource', array('key'=>'value'));
Where resource
is one of pages
, blocks
, variables
, blog/posts
, blog/categories
, blog/tags
, blog/authors
., (*15)
The second (optional) param is an array of key=>value pairs known as attributes. ie. array('page_slug'=>'about-us')
, (*16)
Each resource has the following optional params:, (*17)
There is a third optional param for use with the blog/posts resource. This is an array of resources to exclude (tags, categories, authors), (*18)
resource: pages
, (*19)
Params:, (*20)
To get all pages:, (*21)
$pages = Defaqto::setup($app_id, $access_token)->get('pages'); var_dump($pages);
To get a page by page_slug
, (*22)
$page = Defaqto::setup($app_id, $access_token)->get('pages', array('page_slug'=>'about-us')); echo $page['title'];
resource: blocks
, (*23)
Params:, (*24)
To get all blocks:, (*25)
$blocks = Defaqto::setup($app_id, $access_token)->get('blocks'); var_dump($blocks);
To get a block by block_id
, (*26)
$block = Defaqto::setup($app_id, $access_token)->get('blocks', array('block_id'=>1234)); echo $block['content'];
resource: variables
, (*27)
Params:, (*28)
To get all variables:, (*29)
$variables = Defaqto::setup($app_id, $access_token)->get('variables'); var_dump($variables);
To get a variable by it's key
, (*30)
$variable = Defaqto::setup($app_id, $access_token)->get('variables', array('key'=>'pricing')); echo $variable['value'];
resource: blog/posts
, (*31)
Params:, (*32)
To get all (published) posts:, (*33)
$posts = Defaqto::setup($app_id, $access_token)->get('blog/posts'); var_dump($posts);
To get a post by it's post_slug
, (*34)
$post = Defaqto::setup($app_id, $access_token)->get('blog/posts', array('post_slug'=>'hello-world')); echo $post['title'];
To get all posts by tag (tag_slug
), (*35)
$posts = Defaqto::setup($app_id, $access_token)->get('blog/posts', array('tag_slug'=>'javascript')); var_dump($posts);
To get all posts without their authors, tags, or categories, (*36)
$posts = Defaqto::setup($app_id, $access_token)->get('blog/posts', array(), array('authors', 'tags', 'categories'));
resource: blog/categories
, (*37)
Params:, (*38)
To get all categories:, (*39)
$cats = Defaqto::setup($app_id, $access_token)->get('blog/categories'); var_dump($cats);
To get a category by it's slug, (*40)
$category = Defaqto::setup($app_id, $access_token)->get('blog/categories', array('category_slug'=>'announcements')); echo $category['name'];
resource: blog/tags
, (*41)
Params:, (*42)
To get all tags:, (*43)
$tags = Defaqto::setup($app_id, $access_token)->get('blog/tags'); var_dump($tags);
To get a tag by it's slug, (*44)
$tag = Defaqto::setup($app_id, $access_token)->get('blog/tags', array('tag_slug'=>'javascript')); echo $tag['name'];
resource: blog/authors
, (*45)
Params:, (*46)
To get all authors:, (*47)
$authors = Defaqto::setup($app_id, $access_token)->get('blog/authors'); var_dump($authors);
To get an author by their username, (*48)
$author = Defaqto::setup($app_id, $access_token)->get('blog/authors', array('username'=>'jonesy')); echo $author['bio'];
PHP package for interacting with the Defaqto.io API.