bickart/marketo-php

Marketo PHP REST API客户端

dev-master 2016-09-26 20:52 UTC

This package is not auto-updated.

Last update: 2024-09-28 19:42:03 UTC


README

Version Total Downloads License CodeClimate Test Coverage Build Status

Marketo API客户端。这是我HubSpot/haPihP完美功能的包装器的后续作品。然而,这是一个完全重写的版本,并包括一些新的COS/v2端点。

公告!

设置

Composer

composer require "bickart/marketo-php:1.0.*@dev"

快速入门

使用工厂的示例

所有以下示例都假设这一步骤。

$hubspot = Amaiza\Marketo\Factory::create('api-key');

// OR instantiate by passing a configuration array.
// The only required value is the 'key'

$hubspot = new Amaiza\Marketo\Factory([
  'key'      => 'demo',
  'oauth'    => false, // default
  'base_url' => 'https://api.hubapi.com' // default
]);

注意: 如果在实例化时没有包含API密钥或oauth令牌,客户端类会检查HUBSPOT_SECRET环境变量。

获取单个联系信息

$contact = $hubspot->contacts()->getByEmail("test@hubspot.com");

echo $contact->properties->email->value;

遍历所有联系信息

// Get an array of 10 contacts
// getting only the firstname and lastname properties
// and set the offset to 123456
$response = $hubspot->contacts()->all([
    'count'     => 10,
    'property'  => ['firstname', 'lastname'],
    'vidOffset' => 123456,
]);

与数据交互非常简单!

foreach ($response->contacts as $contact) {
    echo sprintf(
        "Contact name is %s %s." . PHP_EOL,
        $contact->properties->firstname->value,
        $contact->properties->lastname->value
    );
}

// Info for pagination
echo $response->{'has-more'};
echo $response->{'vid-offset'};

或者如果您更喜欢使用数组访问?

foreach ($response['contacts'] as $contact) {
    echo sprintf(
        "Contact name is %s %s." . PHP_EOL,
        $contact['properties']['firstname']['value'],
        $contact['properties']['lastname']['value']
    );
}

// Info for pagination
echo $response['has-more'];
echo $response['vid-offset'];

现在,响应方法实现了PSR-7 ResponseInterface

$response->getStatusCode()   // 200;
$response->getReasonPhrase() // 'OK';
// etc...

无工厂示例

<?php

require 'vendor/autoload.php';

use Amaiza\Marketo\Http\Client;
use Amaiza\Marketo\Resources\Contacts;

$client = new Client(['key' => 'demo']);

$contacts = new Contacts($client);

$response = $contacts->all();

foreach ($response->contacts as $contact) {
    //
}

状态

如果您看到了未计划但想要的内容,请创建问题,我有很大可能会添加它。

  • 公司 🆕
  • 潜在客户 🆕
  • 机会 🆕
  • 机会角色 🆕
  • 销售人员 🆕
  • 统计数据