Skip to content
Hacker News API client for PHP
PHP
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tests/Client
.gitignore
LICENSE
README.md
composer.json
phpunit.xml.dist

README.md

HackerNewsApi

A HN Api client wrapper for PHP, built to experiment with Guzzle services.

Installation

The package is available through composer:

$ composer require mgerarts/hn-api-php

Usage

The client is a wrapper around a Guzzle service definition. It can be instantiated like this:

<?php

use HackerNewsApi\Service\HackerNewsServiceClient;
use HackerNewsApi\Client\HackerNewsClient;

$client = new HackerNewsClient(HackerNewsServiceClient::create());

You can then start making requests:

<?php

$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
// }

A full list of available methods can be found here.

You can’t perform that action at this time.