定制 versium/reach-api-php-sdk 二次开发

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

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

versium/reach-api-php-sdk

最新稳定版本:v0.4.0

Composer 安装命令:

composer require versium/reach-api-php-sdk

包简介

A PHP client library for accessing the Versium REACH APIs.

README 文档

README

A simplified PHP interface for accessing the Versium Reach APIs

Installation

From the root of your project, use composer to install the SDK from packagist.

composer require versium/reach-api-php-sdk

Usage

  1. Use ReachClient
use Versium\Reach\ReachClient;
  1. Create a ReachClient instance, with your API Key, an optional callback function for logging, and an optional queries-per-second rate limit.
$loggingFunction = function($msg) {
    //print out message for dev
    echo $msg;
};
$client = new ReachClient('you-api-key', $loggingFunction);

Note: remember to update the $qps value if Versium customer services increases your rate limit.

  1. For adding data to a set of inputs, use the append function. This function returns a Generator that yields arrays containing API responses. Check the API documentation for which data tools and output types are available.
//call the contact API to append phones and emails 
$inputs = [
    [
        'first' => 'john',
        'last' => 'doe',
        'address' => '123 Trinity St',
        'city' => 'Redmond',
        'state' => 'WA',
        'zip' => '98052',
    ]
];

foreach ($client->append('contact', $inputs, ['email', 'phone']) as $results) {
    //filter out failed queries for processing later
    $failedResults = array_filter($results, function ($result) {
        return !$result->success;
    });
    
    //merge successful matches with inputs
    foreach ($results as $idx => $result) {
        if ($result->matchFound) {
            $inputs[$idx]['appendResults'] = $result->body->versium->results;
        }        
    }
}
  1. For retrieving a list of records, use the listgen function. This function returns a single APIResponse object. This object contains the getRecordsFunc property for iterating through the returned records. Check the API documentation for which data tools and output types are available.
$result = $client->listgen('abm', ['domain' => ['versium.com']], ['abm_email', 'abm_online_audience']);

if ($result->success) {
    foreach (($result->getRecordsFunc)() as $record) {
        var_dump($record);
    }
}

Returned Results

Both the append and listgen functions return one or more APIResponse objects. See the comments in the class for descriptions of its properties.

Things to keep in mind

  • The default rate limit for Reach APIs is 20 queries per second
  • You must have a provisioned API key for this function to work. If you are unsure where to find your API key, look at our API key documentation

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2022-12-28