0

我在本地工作以测试 SendInBlue 创建联系人。

Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('api-key', env('SENDINBLUE_API_KEY'));

$api_instance = new Swagger\Client\Api\ContactsApi();
$createContact = new Swagger\Client\Model\CreateContact();

$createContact['email'] = 'email@gmail.com';
$createContact['listIds'] = 2;

$result = $api_instance->createContact($createContact);

dd($result);

我有这个错误...

[400] 连接到 API 时出错 ( https://api.sendinblue.com/v3/contacts )

4

1 回答 1

2

使用 github 文档

<?php

require_once(DIR . 'autoload.php');

// Configure API key authorization: api-key
SendinBlue\Client\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOUR API');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// SendinBlue\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer');

$api_instance = new SendinBlue\Client\Api\ContactsApi();
$createContact = new \SendinBlue\Client\Model\CreateContact(); // \SendinBlue\Client\Model\CreateContact | Values to create a contact

$createContact['email'] = 'email@gmails.com';


try {
    $result = $api_instance->createContact($createContact);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling ContactsApi->createContact: ', $e->getMessage(), PHP_EOL;
}
?>
于 2017-10-11T12:10:07.243 回答