seanmcn/php-represent
Composer 安装命令:
composer require seanmcn/php-represent
包简介
A PHP library for http://represent.opennorth.ca/
README 文档
README
A PHP library for http://represent.opennorth.ca/
Find the elected officials and electoral districts for any Canadian address or postal code, at all levels of government
Install
Install using composer:
"require": {
"seanmcn/php-represent": "1.*"
}
Alternatively you could just download the package and load it in yourself.
Example Usage
$represent = new PHPRepresent\API();
$represent->getAll('boundaries', ['sets' => ['toronto-wards', 'ottawa-wards']]);
API Documentation
Library Documentation
get($path, $params, $throttle);
Returns a single result or one page of results from API path and parameters provided.
Parameters:
$path- The API Path of your request.$params- $_GET variables you want to append to the request. Allows supplying multiple values per key by array or comma seperated.$throttle- Default TRUE. Option to ignore the API rate limit.
Example Usage:
$represent = new PHPRepresent\API(); $path = 'boundaries'; $params = ['sets' => ['toronto-wards', 'ottawa-wards']]; $represent->get($path, $params);
getAll($path, $params);
Returns all results from API path and parameters provided.
Parameters:
$path- The API Path of your request.$params- $_GET variables you want to append to the request. Allows supplying multiple values per key by array or comma seperated.
Example Usage:
$represent = new PHPRepresent\API(); $path = 'boundaries'; $params = ['sets' => 'toronto-wards,ottawa-wards']; $represent->getAll($path, $params);
postcode($postcode);
Find representatives and boundaries by postal code.
Parameters:
$postcode- Post code to find representatives and boundaries for.
Example Usage:
$represent = new PHPRepresent\API(); $represent->postcode('L5G4L3');
boundarySets($name, $params);
Return boundary sets which are groups of electoral districts, like BC provincial districts or Toronto wards.
Parameters:
$name- Optional, if provided will return the singular boundary set.$params- $_GET variables you want to append to the request. Allows supplying multiple values per key by array or comma seperated.
Example Usage:
$represent = new PHPRepresent\API(); $represent->boundarySets();
boundaries($boundarySet, $name, $representatives, $params)
Return boundaries of electoral districts, can be proved a set like toronto-wards for boundaries of a singular set.
All Parameters are optional however
$namerequires you provide$boundarySetand$representativesrequires you provided both$boundarySetand$name
Parameters:
$boundarySet- Optional, if provided returns boundaries from a singular boundary set$name- Optional, if provided will return a singular boundary$representatives- Optional, if provided will return representatives for the boundary.$params- Optional, $_GET variables you want to append to the request. Allows supplying multiple values per key by array or comma seperated.
Example Usage:
$represent = new PHPRepresent\API(); // One Set $represent->boundaries('toronto-wards'); // Multiple Sets $represent->boundaries(null, null, false, ['sets' => ['toronto-wards', 'ottawa-wards']]);
representativeSets($set);
Returns all or a singular representative set.
A representative set is a group of elected officials, like the House of Commons or Toronto City Council.
Parameters:
$set- Optional, if provided will return the singular represenative set.
Example Usage:
$represent = new PHPRepresent\API(); $represent->representativeSets('north-dumfries-township-council');
representatives($set, $params);
Returns a list of representatives.
Parameters:
$set- Optional, if provided will return the represenatives for a singular set.$params- Optional,$_GETvariables you want to append to the request. Allows supplying multiple values per key by array or comma seperated.
Example Usage:
$represent = new PHPRepresent\API(); $represent->representatives('house-of-commons');
elections($election);
Returns a list of elections or a singular election.
This doesn't have any data right now so I am usnure if this is working correctly.
Parameters:
$election- Optional, if provided will return the a singular election based on provided ID.
Example Usage:
$represent = new PHPRepresent\API(); $represent->elections();
candidates($election, $params);
Returns a list of all candidates for all elections or all candidates for a singular election
This doesn't have any data right now so I am unsure if this is working correctly.
Parameters:
$election- Optional, if provided will return the candidates for a singular election.$params- Optional,$_GETvariables you want to append to the request. Allows supplying multiple values per key by array or comma seperated.
Example Usage:
$represent = new PHPRepresent\API(); $represent->candidates();
setInsecure();
Option to disable using HTTPS, if for example you are having certificate problems while testing this out.
Note: You really shouldn't use this in Production
Example Usage:
$represent = new PHPRepresent\API(); $represent->setInsecure(); $represent->boundaries('toronto-wards');
setRateLimit($limit);
Option to set the rate limit (per minute) to whatever you choose. The default rate limit is 60 requests per minute.
Note: Don't change this unless you have agreed upon a higher rate limit with Open North otherwise you're going to get HTTP 503 errors
Example Usage:
$represent = new PHPRepresent\API(); $represent->setRateLimit(42); $represent->boundaries('ottawa-wards');
seanmcn/php-represent 适用场景与选型建议
seanmcn/php-represent 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 248.81k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2016 年 03 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「api」 「library」 「represent」 「canada」 「opennorth」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 seanmcn/php-represent 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 seanmcn/php-represent 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 seanmcn/php-represent 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
Inbox pattern process implementation for your Laravel Applications
Core library that defines common interfaces used by the rest of the intahwebz..
Amqp classes
Provides command to manage a web library directory
Alfabank REST API integration
统计信息
- 总下载量: 248.81k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0
- 更新时间: 2016-03-30