定制 codelinefi/mac-lookup 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

codelinefi/mac-lookup

Composer 安装命令:

composer require codelinefi/mac-lookup

包简介

PHP client library for macaddress.io API.

README 文档

README

PHP library for MAC Vendor Lookup API by macaddress.io

Installation

You can install the library via Composer

composer require codelinefi/mac-lookup

To use the library, use Composer's autoload

require_once('vendor/autoload');

Requirements

Supported PHP versions:

  • PHP 5.5.x
  • PHP 5.6.x
  • PHP 7.0.x
  • PHP 7.1.x
  • PHP 7.2.x

Dependencies:

  • mbstring
  • mbregex
  • json
  • curl

Documentation

Full API documentation is available here

Getting started

Basic usage

<?php

use CodeLine\MacLookup\Builders\ClientBuilder;

$builder = new ClientBuilder();
$client = $builder->build('Your API key');

echo $client->get('F041C81')->blockDetails->dateUpdated . PHP_EOL;
echo $client->getRawData('18810E') . PHP_EOL;
echo $client->getVendorName('F041C81') . PHP_EOL;

Advanced usage

<?php

use CodeLine\MacLookup\Builders\ResponseModelBuilder;
use CodeLine\MacLookup\Clients\GuzzleClient;
use CodeLine\MacLookup\ApiClient;
use \GuzzleHttp\Client;

$requestor = new GuzzleClient(new Client());
$builder = new ResponseModelBuilder('');
$client = new ApiClient($requestor, $builder, 'Your API key');

echo $client->get('18810E')->vendorDetails->companyName . PHP_EOL;
echo $client->getRawData('18810E') . PHP_EOL;
echo $client->getVendorName('18810E') . PHP_EOL;

Be careful! This library uses trigger_error function with E_USER_DEPRECATED constant to inform you about API updates

Examples

You may find some examples in the example directory. To run these examples execute the following commands:

export API_KEY="<Your api key>"
php vendor.php
php basic.php

Classes

ApiClient class

/**
 * ApiClient constructor.
 * @param \CodeLine\MacLookup\Clients\ClientInterface $client
 * @param \CodeLine\MacLookup\Builders\ResponseModelBuilderInterface $builder
 * @param string $apiKey Your API key
 * @param string $url API base URl
*/
public function __construct(
    ClientInterface $client,
    ResponseModelBuilderInterface $builder,
    $apiKey,
    $url = ""
)

/**
 * @param string $url API base URl
 */
public function setBaseUrl($url);

/**
 * @param string $apiKey Your API key
 */
public function setApiKey($apiKey);

/**
 * @param string $mac Mac address or OUI
 * @return \CodeLine\MacLookup\Models\Response
 * @throws EmptyResponseException
 * @throws ServerErrorException
 * @throws UnknownOutputFormatException
 * @throws AuthorizationRequiredException
 * @throws NotEnoughCreditsException
 * @throws AccessDeniedException
 * @throws InvalidMacOrOUIException
 */
public function get($mac);

/**
 * @param string $mac Mac address or OUI
 * @param string $format Supported formats json/xml/csv/vendor
 * @return string
 * @throws EmptyResponseException
 * @throws ServerErrorException
 * @throws UnknownOutputFormatException
 * @throws AuthorizationRequiredException
 * @throws NotEnoughCreditsException
 * @throws AccessDeniedException
 * @throws InvalidMacOrOUIException
 */
public function getRawData($mac, $format = 'json');

/**
 * @param string $mac Mac address or OUI
 * @return string
 * @throws ServerErrorException
 * @throws UnknownOutputFormatException
 * @throws AuthorizationRequiredException
 * @throws NotEnoughCreditsException
 * @throws AccessDeniedException
 * @throws InvalidMacOrOUIException
*/
public function getVendorName($mac);

Models

namespace CodeLine\MacLookup\Models

Response

/**
 * @var VendorDetails
 */
public $vendorDetails;

/**
 * @var BlockDetails
 */
public $blockDetails;

/**
 * @var MacAddressDetails
 */
public $macAddressDetails;

VendorDetails

/**
 * @var string
 */
public $oui;

/**
 * @var boolean
 */
public $isPrivate;

/**
 * @var string
 */
public $companyName;

/**
 * @var string
 */
public $companyAddress;

/**
 * @var string
 */
public $countryCode;

BlockDetails

/**
 * @var boolean
 */
public $blockFound;

/**
 * @var string
 */
public $borderLeft;

/**
 * @var string
 */
public $borderRight;

/**
 * @var int|float
 */
public $blockSize;

/**
 * @var string
 */
public $assignmentBlockSize;

/**
 * @var \DateTimeInterface
 */
public $dateCreated;

/**
 * @var \DateTimeInterface
 */
public $dateUpdated;

MacAddressDetails

/**
 * @var string
 */
public $searchTerm;

/**
 * @var boolean
 */
public $isValid;

/**
 * @var string
 */
public $transmissionType;

/**
 * @var string
 */
public $administrationType;

ClientBuilder

namespace \CodeLine\MacLookup\Builders

/**
 * @param string $apiKey
 * @param string $url
 * @return \CodeLine\MacLookup\ApiClient
 */
public function build($apiKey, $url = '');

Development

Install composer

Clone code from repository

git clone https://github.com/CodeLineFi/maclookup-php.git

Install dependencies

composer install

Running tests

./vendor/bin/phpunit --testdox tests

codelinefi/mac-lookup 适用场景与选型建议

codelinefi/mac-lookup 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 15 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 09 月 20 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 codelinefi/mac-lookup 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-09-20