PHP code example of nonsoniyi / the-guardian-api-client
1. Go to this page and download the library: Download nonsoniyi/the-guardian-api-client 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/ */
nonsoniyi / the-guardian-api-client example snippets
$api = new Guardian\GuardianAPI(THE_GUARDIAN_API_KEY);
$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();