eventfarm/marketo-client
Composer 安装命令:
composer require eventfarm/marketo-client
包简介
A PHP client for the Marketo REST API.
关键字:
README 文档
README
This package provides an interface for interacting with the Marketo REST API.
Installation
$ composer require eventfarm/marketo-client
Or add the following lines to your composer.json file:
{
"require": {
"eventfarm/marketo-client": "dev-master"
}
}
$ composer install
Project Defaults
In order to get you up and running as easily as possible, we provide default implementations of a REST client and Marketo provider to use in combination with this package.
- We've chosen to use Guzzle for sending HTTP requests
- We've chosen to use The PHP League's Oauth Client and my Marketo provider for Marketo authentication and token refresh.
Guzzle REST Client
Our REST client implements the PSR-7 HTTP message interface.
You can either use the provided GuzzleRestClient or have your own that implements our RestClientInterface.
KristenlkMarketoProvider
Our default Marketo provider is my Marketo Provider library.
You can either use the provided KristenlkMarketoProvider or use your own that implements our MarketoProviderInterface.
Example Client Implementation
<?php namespace App; use EventFarm\Marketo\Oauth\AccessToken; use EventFarm\Marketo\MarketoClient; use EventFarm\Marketo\TokenRefreshInterface; class DemoMarketoClient implements TokenRefreshInterface { public function getMarketoClient():MarketoClient { if (empty($this->marketo)) { $this->marketo = MarketoClient::withDefaults( 'ACCESS_TOKEN', 'TOKEN_EXPIRES_IN', // when the current access token expires (in seconds) 'TOKEN_LAST_REFRESH', // when the current access token was last refreshed (as a UNIX timestamp) 'CLIENT_ID', 'CLIENT_SECRET', 'BASE_URL', $this // TokenRefreshInterface ); } return $this->marketo; } public function tokenRefreshCallback(AccessToken $token) { // CALLBACK FUNCTION TO STORE THE REFRESHED $token TO PERSISTENCE LAYER } }
Usage
Campaigns
Get Campaigns
Docs Returns a list of campaign records. Refer to the docs for the full list of options.
public function getCampaigns(array $options = array())
<?php $demoMarketoClient = new DemoMarketoClient()->getMarketoClient(); $options = [ "programName" => "My Marketo Program", "batchSize" => 10 ]; $campaigns = $demoMarketoClient->campaigns()->getCampaigns($options); // getCampaigns() can also be called without options. // $campaigns = { ... }
Trigger Campaign
Docs Passes a set of leads to a trigger campaign to run through the campaign's flow. Refer to the docs for the full list of options.
- A
campaignIdand an array of options that includes aninputkey (mapped to an array that contains arrays of lead data) must be passed totriggerCampaign().
public function triggerCampaign(int $campaignId, array $options)
<?php $demoMarketoClient = new DemoMarketoClient()->getMarketoClient(); $campaignId = 1029; $options = [ "input" => [ "leads" => [ [ "id" => 1234 ] ] ]//, additional options ]; $campaign = $demoMarketoClient->campaigns()->triggerCampaign($campaignId, $options); // $campaign = { ... }
Lead Fields
Get Lead Fields
Docs Returns metadata about lead objects in the target instance, including a list of all fields available for interaction via the APIs.
public function getLeadFields(array $options = array())
<?php $demoMarketoClient = new DemoMarketoClient()->getMarketoClient(); $leadFields = $demoMarketoClient->leadFields()->getLeadFields(); // $leadFields = { ... }
Leads
Create or Update Leads
Docs Syncs a list of leads to the target instance. Refer to the docs for the full list of options.
- An array of options that includes an
inputkey (mapped to an array that contains arrays of lead data) must be passed tocreateOrUpdateLeads().
public function createOrUpdateLeads(array $options)
By default, Marketo sets the type of sync operation (action) to createOrUpdate and the lookupField to email. If using those defaults:
- Email is not required; if an email is not included in a lead array, Marketo will create a lead without an email.
- When an email is included, Marketo will search for existing leads with that email. If one is found, Marketo will update the found lead with the data sent; if one is not found, Marketo will create a new lead with the data sent.
<?php $demoMarketoClient = new DemoMarketoClient()->getMarketoClient(); $options = [ "input" => [ [ "email" => "email1@example.com", "firstName" => "Example1First", "lastName" => "Example1Last" ], [ "email" => "email2@example.com", "firstName" => "Example2First", "lastName" => "Example2Last" ] ]//, additional options ]; $leads = $demoMarketoClient->leads()->createOrUpdateLeads($options); // $leads = { ... }
Update Leads' Program Status
Docs Changes the program status of a list of leads in a target program. Refer to the docs for the full list of options.
- A
programIdand an array of options that includes aninputkey (mapped to an array that contains arrays of lead data) and astatuskey (mapped to a program status) must be passed toupdateLeadsProgramStatus().
public function updateLeadsProgramStatus(int $programId, array $options)
<?php $demoMarketoClient = new DemoMarketoClient()->getMarketoClient(); $programId = 1234; $options = [ "input" => [ [ "id" => 1111 ] ], "status" => "Registered" ]; $leads = $demoMarketoClient->leads()->updateLeadsProgramStatus($programId, $options); // $leads = { ... }
Get Leads by Program
Docs Retrieves a list of leads that are members of the designated program. Refer to the docs for the full list of options.
- A
programIdmust be passed togetLeadsByProgram().
public function getLeadsByProgram(int $programId, array $options = array())
<?php $demoMarketoClient = new DemoMarketoClient()->getMarketoClient(); $programId = 1234; $options = [ "fields" => 'firstName,lastName,email,middleName,mktoIsPartner'; ]; $leads = $demoMarketoClient->leads()->getLeadsByProgram($programId, $options); // getLeadsByProgram() can also be called without options. // $leads = { ... }
Lead Partitions
Get Lead Partitions
Docs Returns a list of available partitions in the target instance. Refer to the docs for the full list of options.
public function getPartitions(array $options = array())
<?php $demoMarketoClient = new DemoMarketoClient()->getMarketoClient(); $partitions = $demoMarketoClient->partitions()->getPartitions(); // $partitions = { ... }
Programs
Get Programs
Docs Retrieves the list of accessible programs from the target instance. Refer to the docs for the full list of options.
public function getPrograms(array $options = array())
<?php $demoMarketoClient = new DemoMarketoClient()->getMarketoClient(); $programs = $demoMarketoClient->programs()->getPrograms(); // $programs = { ... }
Statuses
Get Statuses
Docs Retrieves channels based on the provided name. Refer to the docs for the full list of options.
- A
programChannelmust be passed togetStatuses().
public function getStatuses(string $programChannel, array $options = array())
<?php $demoMarketoClient = new DemoMarketoClient()->getMarketoClient(); $programChannel = "Live Event"; $programs = $demoMarketoClient->statuses()->getStatuses($programChannel); // $programs = { ... }
eventfarm/marketo-client 适用场景与选型建议
eventfarm/marketo-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7.85k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2016 年 10 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「Marketo」 「Marketo API」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 eventfarm/marketo-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 eventfarm/marketo-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 eventfarm/marketo-client 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Provides a Laravel 5 service provider and facade for Marketo REST API Client.
Marketo Rest Api Client
Laravel Marketo Rest Api
Marketo OAuth 2.0 support for the PHP League's OAuth2-Client
A PSR-7 compatible library for making CRUD API endpoints
Marketo SOAP API PHP Client
统计信息
- 总下载量: 7.85k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-10-27