schibsted-tech-polska/php-sndapi
最新稳定版本:1.0.0
Composer 安装命令:
composer require schibsted-tech-polska/php-sndapi
包简介
SND API v2 client
关键字:
README 文档
README
This is a packagist-friendly SND API client built by Stavanger Aftenblad's team. The API uses application/json content type with UTF-8 charset. Each method returns result of json_decode run on result. This is not configurable yet, however we plan to introduce entity hydrators (along with entities) in near future.
Client provides console access to the API:
bin/sndapi-console
Console usage requires three parameters:
Options: --key (-s) SND API key --secret (-s) SND API secret --publicationId (-p) SND API publication id (common, sa, fvn, bt, ap)
Requirements
- php >= 5.5
- composer
- node & npm
Installation
In order to add the library to your project just run:
composer require "Schibsted-Tech-Polska/php-sndapi"
Development
Feel free to develop new parts of the library, but have in mind that it's fully tested with PHP Unit and you should use pull requests in order to merge your code.
News
The library uses v2 snd news api described here. Authentication requires valid API secret, every API method also requires publicationId. Publication ID is one of the following:
- common
- ap
- bt
- fvn
- sa
Usage
Initialize the library with
<?php use Stp\SndApi\News\Client as NewsClient; const API_KEY = 'mnbvcxzlkjhgfdsapoiuytrew'; const API_SECRET = 'qwertyuiopasdfghjklzxcvbn'; const PUBLICATION_ID = 'sa'; $newsClient = new NewsClient(API_KEY, API_SECRET, PUBLICATION_ID);
Methods
getServiceDocument
Returns service document.
http://developers.snd.no/doc/news/documentation/publication.
<?php $newsClient->getServiceDocument();
Console:
bin/sndapi-console news:servicedocument [-s|--secret="..."] [-p|--publicationId="..."]
getImageVersions
$newsClient->getImageVersions();
Console:
```sh
bin/sndapi-console news:image:versions [-s|--secret="..."] [-p|--publicationId="..."]
#### getSectionsList
Returns sections list.
[http://developers.snd.no/doc/news/documentation/section#listsections](http://developers.snd.no/doc/news/documentation/section#listsections)
```php
<?php
$newsClient->getSectionsList();
Console:
bin/sndapi-console news:sections:list [-s|--secret="..."] [-p|--publicationId="..."]
getSubsectionsList
Returns subsections list.
http://developers.snd.no/doc/news/documentation/section#listsections
<?php $newsClient->getSubsectionsList(217);
getSectionByUniqueName
Finds a section using its unique name.
http://developers.snd.no/doc/news/documentation/section#getsection
<?php $newsClient->getSectionByUniqueName('nyheter');
Console:
bin/sndapi-console news:section:uniquename [-s|--secret="..."] [-p|--publicationId="..."] name
getSectionById
Similar to previous one, but finds a section using its id.
http://developers.snd.no/doc/news/documentation/section#getsection
<?php $newsClient->getSectionById(217);
Console:
bin/sndapi-console news:section:id [-s|--secret="..."] [-p|--publicationId="..."] id
getArticlesBySectionId
Finds a list of articles using section id or section's unique name.
http://developers.snd.no/doc/news/documentation/article#listarticles
Parameters
Numeric parameters
- areaLimit
- offset
- limit
Boolean values
- includeSubsections
- homeSectionOnly
<?php $newsClient->getArticlesBySectionId( 217, 'desked', [ 'limit' => 50 ] );
Console:
bin/sndapi-console news:section:articles [-s|--secret="..."] [-p|--publicationId="..."] id method [parameters1] ... [parametersN]
getArticle
Retrieves one article, alias to searchByInstance but with article provided as contentType.
http://developers.snd.no/doc/news/documentation/article#getarticle
<?php $newsClient->getArticle(3687148);
Console:
bin/sndapi-console news:article:id [-s|--secret="..."] [-p|--publicationId="..."] id
searchByInstance
Returns search result of a specified contentId and contentType.
http://developers.snd.no/doc/news/documentation/search#byinstance
<?php $newsClient->searchByInstance(3687148, 'article');
Console:
bin/sndapi-console news:search:instance [-s|--secret="..."] [-p|--publicationId="..."] id contentType
searchByCollection
Returns search results of provided content ids.
http://developers.snd.no/doc/news/documentation/search#bycollection
<?php $newsClient->searchByInstance([123456, 789012]);
Console:
bin/sndapi-console news:search:collection [-s|--secret="..."] [-p|--publicationId="..."] ids1 ... [idsN]
Not implemented yet:
searchResource
http://developers.snd.no/doc/news/documentation/search#searchres
searchByTags
http://developers.snd.no/doc/news/documentation/search#bytags
searchByQuery
http://developers.snd.no/doc/news/documentation/search#byquery
schibsted-tech-polska/php-sndapi 适用场景与选型建议
schibsted-tech-polska/php-sndapi 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.75k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2015 年 05 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「schibsted」 「stp」 「snd」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 schibsted-tech-polska/php-sndapi 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 schibsted-tech-polska/php-sndapi 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 schibsted-tech-polska/php-sndapi 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
OAuth2 client for Schibsted account
A lightweight plain-PHP framework for database-backed CRUD APIs.
Modern, strongly-typed, PSR-compliant PHP client for the WeFact v2 API.
统计信息
- 总下载量: 2.75k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-05-06