blua-blue/blua-blue-php-sdk 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

blua-blue/blua-blue-php-sdk

Composer 安装命令:

composer require blua-blue/blua-blue-php-sdk

包简介

PHP SDK for blua.blue

README 文档

README

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

Installation

composer require blua-blue/blua-blue-php-sdk

Usage

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) {
 ...
}

Client Methods

Constructor

$bluaBlue = new Client($publicKey, $apiKey=null, $apiEndpoint = 'https://blua.blue')

getArticle($articleSlugOrID)

This method accepts either the unique ID or the unique article-slug of a particular article.

getOwnArticles()

Retrieves all owned articles regardless of publish-state

getArticlesByKeywords($keywords)

Comma-seperated or single keyword e.g.

$phpTutorials = getArticlesByKeywords('php,tutorial');

getCategories()

Retrieves a list of available categories

getImages()

Retrieves stored images

registerImage($pathOrBase64, $mode='external')

MODES: external | upload

Either registers external images for reference or accepts base64 encoded image strings. (all browser-native content-types, max 600kb)

createArticle($article)

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);

updateArticle($article)

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);

Article Wrapper

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()

Image Wrapper

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'

Additional methods on Article and Image

toArray()

Exports object into assoc-array.

Additional method on Article

getContentHtml()

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'];
}

blua-blue/blua-blue-php-sdk 适用场景与选型建议

blua-blue/blua-blue-php-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 21 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 11 月 30 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 blua-blue/blua-blue-php-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 blua-blue/blua-blue-php-sdk 我们能提供哪些服务?
定制开发 / 二次开发

基于 blua-blue/blua-blue-php-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 21
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2019-11-30