Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rohit-chouhan/theguardian-api-php

PHP API Client for The Guardian News.
https://github.com/rohit-chouhan/theguardian-api-php

api api-client free guardiannews newsapi

Last synced: about 1 month ago
JSON representation

PHP API Client for The Guardian News.

Awesome Lists containing this project

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](http://open-platform.theguardian.com/documentation/), In order to connect you will need an api key, which you can be generate from [here](http://open-platform.theguardian.com/access/)

### Usage
To use this client api, first download this gihutb files, and start using.
```php
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
search("test")
->section("technology")
->show_fields("all")
->get_articles();
//you can add more functions to the object

foreach ($articles as $article) {
echo $article->webTitle."
";
}
?>
```
#### 📌 get_article() `Single Item`
```php
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
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
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
search("sport")
->get_editions()
?>
```

#### Developer
This API Client created by [Rohit Chouhan](https://rohitchouhan.com)