承接 rohit-chouhan/theguardian-api-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

rohit-chouhan/theguardian-api-php

Composer 安装命令:

composer require rohit-chouhan/theguardian-api-php

包简介

PHP API Client for The Guardian News.

README 文档

README

PHP API Client for The Guardian News.

Requirements

  • PHP 5.6.0 or greater

The documentation for the Guardian News API can found here, In order to connect you will need an api key, which you can be generate from here

Usage

To use this client api, first download this gihutb files, and start using.

<?php
    require_once 'vendor/autoload.php';
    $theguardian = new TheGuardian('your_api_key');

methods

methods descriptions
$theguardian->get_articles() Content
$theguardian->get_article(id) Single Item
$theguardian->get_tags() Tags
$theguardian->get_sections() Sections
$theguardian->get_editions() Editions

📌 get_articles() Content

A Content module can be utilized as an interface for the content endpoint provided by the Guardian.

<?php
    require_once 'vendor/autoload.php';

    $theguardian = new TheGuardian('test');
    $articles = $theguardian
                ->search("test")
                ->section("technology")
                ->show_fields("all")
                ->get_articles();
    //you can add more functions to the object

    foreach ($articles as $article) {
        echo $article->webTitle."<br>";
    }
?>

📌 get_article() Single Item

<?php
    require_once 'vendor/autoload.php';

    $theguardian = new TheGuardian('test');
    $articles = $theguardian
                ->show_fields("all")
                ->get_article("business/2014/feb/18/uk-inflation-falls-below-bank-england-target");
?>

📌 get_tags() Tags

Tags are returned by the tags endpoint. We manually categorize all Guardian content based on these tags, which number more than 50,000.

<?php
    require_once 'vendor/autoload.php';

    $theguardian = new TheGuardian('test');
    $articles = $theguardian
                ->search("sport")
                ->get_tags()
?>

📌 get_sections() Sections

Using this section module, the Guardian's sections endpoint can be accessed. The guardian's data can be accessed through this link. For example, business, sports, and technology are examples of query parameters (q).

<?php
    require_once 'vendor/autoload.php';

    $theguardian = new TheGuardian('test');
    $articles = $theguardian
                ->search("sport")
                ->get_sections()
?>

📌 get_editions() Editions

All editions in the API are returned by the editions endpoint. An edition is a front main page on the Guardian site. There are currently editions of the Guardian available for the United Kingdom(uk), the United States(us) and Australia(au).

<?php
    require_once 'vendor/autoload.php';

    $theguardian = new TheGuardian('test');
    $articles = $theguardian
                ->search("sport")
                ->get_editions()
?>

Developer

This API Client created by Rohit Chouhan

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-06-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固