定制 schibsted-tech-polska/php-sndapi 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

schibsted-tech-polska/php-sndapi

最新稳定版本:1.0.0

Composer 安装命令:

composer require schibsted-tech-polska/php-sndapi

包简介

SND API v2 client

README 文档

README

Build Status Scrutinizer Code Quality

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

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 16
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-05-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固