PHP code example of mgerarts / hn-api-php
1. Go to this page and download the library: Download mgerarts/hn-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/ */
mgerarts / hn-api-php example snippets
use HackerNewsApi\Service\HackerNewsServiceClient;
use HackerNewsApi\Client\HackerNewsClient;
$client = new HackerNewsClient(HackerNewsServiceClient::create());
$client->getItem(8863);
// Will return:
// HackerNewsApi\Models\Item {#70
// -id: 8863
// -deleted: false
// -type: "story"
// -by: "dhouston"
// -time: 1175714200
// -text: null
// -dead: false
// -parent: null
// -poll: null
// -kids: array:33 [..]
// -url: "http://www.getdropbox.com/u/2/screencast.html"
// -score: 111
// -title: "My YC app: Dropbox - Throw away your USB drive"
// -parts: []
// -descendants: 71
// }
Bash
$ composer