nonsoniyi/the-guardian-api-client 问题修复 & 功能扩展

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

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

nonsoniyi/the-guardian-api-client

最新稳定版本:v1.0.4

Composer 安装命令:

composer require nonsoniyi/the-guardian-api-client

包简介

PHP wrapper for the guardian APIs

README 文档

README

PHP client library for the Guardian APIs. See documentation here. All available API modules are supported - Content, Tags, Sections, Editions, and Single Item.

Installation

You can install this package with composer using the command below

 composer require nonsoniyi/the-guardian-api-client

Get API key

Sign up for an API key here

Making Requests

The primary Guardian\GuardianAPI class is a factory class that creates objects for each of the API modules, allowing you to make requests to any of them with your desired request parameters. You have to first create an object for it, then access your desired API module via the object. See the code snippets below:

$api = new Guardian\GuardianAPI(THE_GUARDIAN_API_KEY);

For Content:

$response = $api->content()
    ->setQuery("12 years a slave")
    ->setTag("film/film,tone/reviews")
    ->setFromDate(new DateTimeImmutable("01/01/2010"))
    ->setToDate(new \DateTimeImmutable())
    ->setShowTags("contributor")
    ->setShowFields("starRating,headline,thumbnail,short-url")
    ->setOrderBy("relevance")
    ->fetch();

For Tags:

$response = $api->tags()
    ->setQuery("apple")
    ->setSection("technology")
    ->setShowReferences("all")
    ->fetch();

For Sections:

$response = $api->sections()
    ->setQuery("business")
    ->fetch();

For Editions:

$response = $api->editions()
    ->setQuery("uk")
    ->fetch();

For Single Item:

$response = $api->singleItem()
    ->setId("/sport/2022/oct/07/cricket-jos-buttler-primed-for-england-comeback-while-phil-salt-stays-focused")
    ->setShowStoryPackage(true)
    ->setShowEditorsPicks(true)
    ->setShowMostViewed(true)
    ->setShowRelated(true)
    ->fetch();

Community support

You can reach out to us on the Google Group here https://groups.google.com/g/guardian-api-talk for support

统计信息

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

GitHub 信息

  • Stars: 6
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-08-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固