The goal of this package is to enable fast, secure and simple integration of your blua.blue content into own web domains. NOTE: this library also works for open-source installations of blua.blue
composer require blua-blue/blua-blue-php-sdk
require __DIR__ . 'vendor/autoload.php';
$client = new BluaBlue\Client('yourPublicKey', 'yourAPIkey');
try{
$client->authenticate();
$myArticles = $client->getOwnArticles();
foreach ($myArticles as $article){
echo $article->getName();
echo $article->getContentHtml();
}
} catch (Exception $e) {
...
}$bluaBlue = new Client($publicKey, $apiKey=null, $apiEndpoint = 'https://blua.blue')
This method accepts either the unique ID or the unique article-slug of a particular article.
Retrieves all owned articles regardless of publish-state
Comma-seperated or single keyword e.g.
$phpTutorials = getArticlesByKeywords('php,tutorial');
Retrieves a list of available categories
Retrieves stored images
MODES: external | upload
Either registers external images for reference or accepts base64 encoded image strings. (all browser-native content-types, max 600kb)
Creates a new article. While you can pass in a simple array, we recommend using the wrapper:
$bluaBlue = new Client(getenv('publicKey'), getenv('apiKey'));
$newArticle = new \BluaBlue\Article();
$newArticle->setName('My awesome article');
$newArticle->setTeaser('What you always wanted to know about me');
$newArticle->setCategoryId('F7A3D7DFA54C11EB9242D83BBF2ADDD8');
$newArticle->setKeywords('biography');
$newArticle->addArticleContent([
'sort'=>1,
'content_type'=>'markdown',
'content'=>'## hi there'
])
//...
$bluaBlue->createArticle($newArticle);Similar to createArticle, but operates on an existing article
$bluaBlue = new Client(getenv('publicKey'), getenv('apiKey'));
$myArticle = $bluaBlue->getArticle('my-awesome-article')
$myArticle->addArticleContent([
'sort'=>count($myArticle->getArticleContent())+1,
'content_type'=>'markdown',
'content'=>'## chapter 2 ...'
]);
//...
$bluaBlue->updateArticle($myArticle);The article wrapper can be constructed with an array:
new Article(['name'=>'How to set up x']) or empty
new Article()
Either way, the wrapper has setters and getters for the following properties:
- $id (getter only)
- $name
- $slug (getter only)
- $teaser
- $image_id
- $author_user_id (setter will be overwritten by endpoint)
- $category_id
- $is_public
- $keywords
- $publish_date
- $insert_date (getter only)
- $update_date
- $delete_date
- $article_content
- $article_store
Example:
$new = new Article();
$new->setName('Title of my article');
echo $new->getName(); // prints 'Title of my article'NOTE: you can let the endpoint determine certain values based on neoan3-db logik:
$article->setDeleteDate('.') will be translated to the current ("point") in time when the request is received.
In other words, the SQL equivalent NOW()
The image wrapper can be constructed with an array:
new Image(['format'=>'image/png']) or empty new Image()
Either way, the wrapper has setters and getters for the following properties:
- id (getter only)
- path
- format
- inserterUserId (getter only)
Example:
$new = new Image();
$new->setPath('https://s3.aws.com/234.asdf');
echo $new->getPath(); // prints 'https://s3.aws.com/234.asdf'Exports object into assoc-array.
Exports a combined HTML-string from all contents
$article = $blueAblue->getArticle('best-article-I-wrote');
$allContent = $article->getContentHtml();
// equivalent to:
$allContent = '';
foreach($article->getArticleContent() as $content){
$allContent .= $content['html'];
}