承接 311archive/http-client 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

311archive/http-client

Composer 安装命令:

composer require 311archive/http-client

包简介

PHP client for the 311.report API.

README 文档

README

PHP client to aid in fetching and processing Boston 311 reports from Boston 311 Archive API.

Example usage

See the example-scripts folder for examples.

Create a CSV of the number of 311 Reports about fireworks per day over the last few years.

  1. Clone this repo or include it in your PHP project.
  2. Instantiate a new Client:
// Instantiate a new Client.
$client = new Balsama\Client();

// Find all Reports that contain the word "fireworks" or a common alternative spelling "fire works" in the description.
$client->filterDescription(['fireworks', 'fire works']);

// Group the results by day
$client->groupResultsByDay();

// Fetch the reports and store them in `$reports`.
$client->fetchReports();
$reports = $client->getReports();

// Format the number of reports per day into a simple `date` and `count` csv suitible for graphing.
\Balsama\Helpers::convertDateValArrayToCsv($reports, 'fireworks.csv');

Documentation

class Client

Public methods

Name Description Parameters Returns
fetchReports Fetches all reports from the API. $this
getReports Gets al of the fetched reports. array
getReportsFields Gets specific fields from the fetched Reports array
setLimit Limit the number of records returned per request. Note that this does not limit the total number of records returned. It just splits them up over more pages/requests. @param int $limit $this
limitRequests Limits the number of requests/pages, even if there are more results to be fetched. @param int $numberOfRequests $this
setOffset Offset the start of the records returned by a given number. @param int $offset $this
dateFilterAfterDate Filters reports that come before the provided "after" date. @param string $afterDate: Any readable PHP date format. $this
dateFilterBeforeDate Filters reports that come after the provided "before" date. @param string $beforeDate: Any readable PHP date format. $this
filterCategory Filters reports to only include reports in the given category. @param string $category $this
filterNeighborhood Filters reports to only include reports from the given neighborhood. @param string $neighborhood $this
filterDescription An array of strings of which at least one must be present in the Description field. @param string[] $description $this
filterStatusOpen Filter on whether the report is open or not. True for open, False for closed. Do not use this method to return all. $this
filterStatusNotes An array of strings which much be present in the Status Notes field. Note: The Status Notes field is populated by the city when a report is closed. It is generally empty for open reports. As such, using this will only return closed reports. `@param string[] $terms $this
groupResultsByDay Groups the results into arrays keyed by day on which they were opened. $this
groupResultsByWeek Groups the results into arrays keyed by Month in which they were opened. $this
groupResultsByMonth Groups the results into arrays keyed by Year in which they were opened. $this

class Helpers

Methods (all methods in the Helpers class are static)

Name Description Parameters Returns
convertDateValArrayToCsv For a typical array of [$date => $value]'s, converts it into a CSV of the given name. @param array $array array
includeArrayKeysInArray Shifts each top level key of an array of arrays into the row's contained array while preserving top-level keys. @param array[] array[]
csv Writes an array of arrays to a CSV file. @param string[] $headers, @param array[] $data, @param string $filename, @param bool $append, @param string $path void
fillMissingDateArrayKeys Given an array keyed by dates, returns an array with any missing date keys filled. @param array $array array
arrayValuesToCounts Given an array of arrays, returns the count of each second level array while preserving top-level array keys. `@param array $array array
fillLowerLevelDates Given an array of arrays keyed by dates, fills each of the arrays with any missing date keys and values based on the earliest start and latest end of all the arrays. @param array[] $array array[]
flattenMultitermDateCount Given an array of arrays keyed by date (with identical numbers of items in each array and the same start and enddate), flattens the array into [date, val1, val2, ...]. @param array[] $arrays array[]

About

Boston 311 Archive is a volunteer project to create a searchable archive of Boston 311 reports. See Boston 311 Archive: About for more information.

Boston 311 Archive also provides an easily discoverable read-only API that conforms to the JSON:API standard. You can browse the API directly at https://311.report/jsonapi.

311archive/http-client 适用场景与选型建议

311archive/http-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 08 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 311archive/http-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 311archive/http-client 我们能提供哪些服务?
定制开发 / 二次开发

基于 311archive/http-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 9
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2020-08-04