mgerarts / hn-api-php
使用 Guzzle 的 Hacker news API 的 PHP 包装器
v1.0.2
2017-05-28 07:59 UTC
Requires
- php: >=7.1
- guzzlehttp/guzzle-services: ^1.1
Requires (Dev)
- phpunit/phpunit: ^6.1
- symfony/var-dumper: ^3.2
This package is auto-updated.
Last update: 2024-09-08 23:11:34 UTC
README
一个 PHP 的 Hacker News API 客户端包装器,用于实验 Guzzle 服务。
安装
该软件包通过 composer 提供
$ composer require mgerarts/hn-api-php
使用方法
客户端是围绕 Guzzle 服务定义的包装器。它可以这样实例化
<?php use HackerNewsApi\Service\HackerNewsServiceClient; use HackerNewsApi\Client\HackerNewsClient; $client = new HackerNewsClient(HackerNewsServiceClient::create());
然后您可以开始发送请求
<?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 // }
可用方法的完整列表可以在 这里 找到。