PHP code example of rohit-chouhan / theguardian-api-php
1. Go to this page and download the library: Download rohit-chouhan/theguardian-api-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rohit-chouhan / theguardian-api-php example snippets
uardian = new TheGuardian('your_api_key');
guardian = 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>";
}
guardian = new TheGuardian('test');
$articles = $theguardian
->show_fields("all")
->get_article("business/2014/feb/18/uk-inflation-falls-below-bank-england-target");
guardian = new TheGuardian('test');
$articles = $theguardian
->search("sport")
->get_tags()
guardian = new TheGuardian('test');
$articles = $theguardian
->search("sport")
->get_sections()
guardian = new TheGuardian('test');
$articles = $theguardian
->search("sport")
->get_editions()
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.