cwhittl/php-pardot-api

为 Pardot (Salesforce.com 公司) API 提供的 API 封装器。

dev-master 2017-02-13 19:06 UTC

This package is not auto-updated.

Last update: 2024-09-23 13:31:42 UTC


README

PHP 封装 Pardot RESTful API

需求

  1. PHP 5.3.*
  2. cURL 库已安装
  3. 安装目录应该是可写的(不是必需的,但强烈推荐)

配置

  1. 在 pardot_config.php 文件中设置电子邮件、密码和 user_key 值
  2. 在 pardot_config.php 文件中设置调试模式和日志设置(可选)

使用方法

  1. 设置命名空间: use \Pardot\API as API;
  2. 使用 3 个主要请求函数进行请求
    1. doOperationById($object, $operation, $id = null, $parameters = null)
    2. doOperationByField($object, $operation, $field = null, $fieldValue = null, $parameters = null)
    3. queryObject($object, $parameters = null)

$object$operation 的值是类文件顶部引用的常量。


<?php
// namespace config
use \Pardot\API as API;
$pardot_config = new \Pardot\Config(
    array(
    'email' => "",
    'password' => "",
    'userkey' => "",
    )
);
// get all prospects updated within the last 2 hours
$prospects = API::Instance($pardot_config)->queryObject(API::OBJ_PROSPECT, array('updated_after' => '2 hours ago'));
var_dump($prospects);

请参阅 example.php 文件以获取完整的用法示例。