承接 freshheads/postcode-api-client 相关项目开发

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

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

freshheads/postcode-api-client

最新稳定版本:4.1.1

Composer 安装命令:

composer require freshheads/postcode-api-client

包简介

Client library for the postcodeapi.nu web service.

README 文档

README

Build Status

FHPostcodeAPIClient is a PHP client library for the PostcodeAPI.nu web service. This library is developed by Freshheads and will be maintained in sync with the web service itself.

Links:

Installation

FHPostcodeAPIClient can easily be installed using Composer:

composer require freshheads/postcode-api-client

Usage

Instantiate the client and replace the API key with your personal credentials:

// Use the composer autoloader to load dependencies require_once 'vendor/autoload.php'; // initiate client $apiKey = 'replace_with_your_own_api_key'; // In this example we made use of the Guzzle as HTTPClient. $client = new \FH\PostcodeAPI\Client( new GuzzleHttp\Client([ 'headers' => [ 'X-Api-Key' => $apiKey ] ]) ); // call endpoints $response = $client->getAddresses('5041EB', 21); $response = $client->getAddress('0855200000061001'); $response = $client->getPostcodeDataByPostcode('5041EB'); // Note that this call is only available with a premium account $response = $client->getPostcodes('51.566405', '5.077171');

Within a Symfony project

We recommend to use Guzzle, to be able to use Guzzle in combination with the PostcodeApiClient. Following definition is used with an implementation of Guzzle 7.

_defaults: autowire: true autoconfigure: true project.http.client.postal_code: class: GuzzleHttp\Client bind: $config: { headers: { X-Api-Key: '%postcode_api_nu.key%' } } FH\PostcodeAPI\Client: $httpClient: '@project.http.client.postal_code'

You should now be able use the FH\PostcodeAPI\Client service to make requests to the PostcodeAPI.

Guzzle 6

To make use of Guzzle 6, you should also make use of the Guzzle6Adapter. By running the following command you automatically install Guzzle as well.

composer require php-http/guzzle6-adapter

And add the following service definitions (usable in Symfony ^3.4):

services: _defaults: autowire: true autoconfigure: true project.http.guzzle.client: class: GuzzleHttp\Client arguments: - { headers: { X-Api-Key: 'replace_with_your_own_api_key_or_variable' } } project.http.adapter.guzzle.client: class: Http\Adapter\Guzzle6\Client arguments: $client: '@project.http.guzzle.client' FH\PostcodeAPI\Client: $httpClient: '@project.http.adapter.guzzle.client'

统计信息

  • 总下载量: 123.77k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 16
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 16
  • Watchers: 10
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固