superdesk/contentapi-sdk-php
Composer 安装命令:
composer create-project superdesk/contentapi-sdk-php
包简介
Superdesk Content API SDK written in PHP
README 文档
README
This is an SDK written in PHP for the Superdesk Content API.
For more information about the Superdesk Content API please read the documentation.
Installation
Requirements
- PHP >= 5.3
When using the CurlApiClient and CurlClient classes make sure you've installed the following PHP extensions:
Composer
- Require the SDK as a composer dependency
$ php composer.phar require superdesk/contentapi-sdk-php
Manual
- Download a copy of the SDK
- Add the classes to your autoloader
Customization
You can use your own client classes instead of CurlClient and CurlApiClient files. This is for example useful if your framework or project already has it's own http client, you can easily incorporate that without having multiple depencencies. All you need to do is to implement the ClientInterface and ClientApiInterface. For the ClientApi class there also a useful abstract class AbstractApiClient which contains some sane defaults.
Examples
This example uses the CurlClient and CurlApiClient files.
You can run the example.php via the cli with the command:
$ php sample/default-client/example.php
Make sure you have the extenions cURL and Multibyte String enabled and you've installed the vendors.
$ php composer.phar install --no-dev
Samples
Authentication
OAuth username and password authentication. The CurlApiClient will automatically try to retrieve new access token if the previous token has been invalited.
<?php use Superdesk\ContentApiSdk\ContentApiSdk; use Superdesk\ContentApiSdk\Client\CurlClient; use Superdesk\ContentApiSdk\Client\CurlApiClient; use Superdesk\ContentApiSdk\Api\Authentication\OAuthPasswordAuthentication; $genericClient = new CurlClient(); $authentication = new OAuthPasswordAuthentication($genericClient); $authentication ->setClientId(API_CLIENT_ID) ->setUsername(API_USERNAME) ->setPassword(API_PASSWORD); $apiClient = new CurlApiClient($genericClient, $authentication); $contentApi = new ContentApiSdk($apiClient, API_HOST, API_PORT, API_PROTOCOL); ?>
Pagination and traversing through results
We use Pagerfanta as a pagination library. All results returned from the methods getItems(...) and getPackages(...) are actually Pagerfanta instances. That should make it easy enough to traverse through your API results and also built in your own pagination.
<?php use Superdesk\ContentApiSdk\ContentApiSdk; $contentApi = new ContentApiSdk(...); $maxPerPage = 1; $startPage = 1; $items = $contentApi->getItems(array(), $startPage, $maxPerPage); $items->getNbResults(); // Total items $items->getMaxPerPage(); // Max results per age == $maxPerPage $items->getNbPages(); // Total pages ?>
superdesk/contentapi-sdk-php 适用场景与选型建议
superdesk/contentapi-sdk-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 85.08k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2015 年 08 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「Superdesk Web Publisher」 「Superdesk」 「Content API SDK」 「Superdesk Content API」 「Superdesk SDK」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 superdesk/contentapi-sdk-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 superdesk/contentapi-sdk-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 superdesk/contentapi-sdk-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This bundle provides tools to build persistence-agnostic storage layer.
Build persistence-agnostic storage layer.
Bridge between JMS Serializer Bundle and Superdesk Web Publisher.
KNP Menu Bundle integrations with Superdesk Publisher.
Model of a web-based resource
Scope and owner aware settings system. Define settings in configuration, keep customized values in storage.
统计信息
- 总下载量: 85.08k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 7
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0
- 更新时间: 2015-08-04