【问题标题】:Mailchimp PHP Marketing API pass request parametersMailchimp PHP Marketing API 传递请求参数
【发布时间】:2021-02-01 05:37:21
【问题描述】:

我正在使用 Mailchimp 的营销 PHP API (https://github.com/mailchimp/mailchimp-marketing-php) 来检索模板列表。它有以下代码。

<?php
require_once '/path/to/MailchimpMarketing/vendor/autoload.php';

$client = new MailchimpMarketing\ApiClient();
$client->setConfig([
    'apiKey' => 'YOUR_API_KEY',
    'server' => 'YOUR_SERVER_PREFIX',
]);

$response = $client->templates->list();
print_r($response);

它返回整套其他默认模板(128 个模板!),api 请求参数有type 字段,可用于过滤这些模板。但是我无论如何都找不到传递请求参数。有什么想法吗?

【问题讨论】:

  • $response = $client->templates->get(
  • @JeetPatel 我不想返回特定模板,而是返回 API 中具有用户类型的模板列表。默认情况下它返回所有 128 个模板,我需要将其过滤掉。

标签: mailchimp mailchimp-api-v3.0 mailchimp-api-v3


【解决方案1】:

我不确定这是否是正确的方法,但在查看 API 库源代码后,我找到了包含请求参数的正确函数。

<?php
require_once '/path/to/MailchimpMarketing/vendor/autoload.php';

$client = new MailchimpMarketing\ApiClient();
$client->setConfig([
    'apiKey' => 'YOUR_API_KEY',
    'server' => 'YOUR_SERVER_PREFIX',
]);

$response = $this->client->templates->listWithHttpInfo($fields = null, $exclude_fields = null, $count = '10', $offset = '0', $created_by = null, $since_created_at = null, $before_created_at = null, $type = 'user', $category = null, $folder_id = null, $sort_field = null);

print_r($response);

【讨论】:

    猜你喜欢
    • 2021-06-04
    • 2021-09-24
    • 2017-08-04
    • 2011-07-05
    • 1970-01-01
    • 2017-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多