我正在为 Codeigniter 搜索 SendinBlue API,但尚未找到。
在 API 尚不存在的情况下,自己编写代码是否很难(我已经知道 HTTP 请求,但我对配置一无所知)
或者可以使用 PHP 吗?
谢谢
我正在为 Codeigniter 搜索 SendinBlue API,但尚未找到。
在 API 尚不存在的情况下,自己编写代码是否很难(我已经知道 HTTP 请求,但我对配置一无所知)
或者可以使用 PHP 吗?
谢谢
我对此有一个很好的解决方案,它对我来说很好,我希望它也对你有用。我正在使用 API-v3。
我所做的是:
这是我的库结构:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Sendinblue{
public $config;
public $apiInstance;
public function __construct(){
require_once('sendinblue/vendor/autoload.php');
$this->config = SendinBlue\Client\Configuration::getDefaultConfiguration()->setApiKey('api-key', '');
$this->apiInstance = new SendinBlue\Client\Api\ContactsApi(
new GuzzleHttp\Client(),
$this->config
);
}
public function get_contact_info($data){
$identifier = $data['email'];
try {
return $result = $this->apiInstance->getContactInfo($identifier);
} catch (Exception $e) {
return 'Exception when calling ContactsApi->getContactInfo: '.$e->getMessage();
}
}
public function create_contact($data){
$createContact = new \SendinBlue\Client\Model\CreateContact();
$createContact['email'] = $data['email'];
$createContact['listIds'] = [2];
try {
return $result = $this->apiInstance->createContact($createContact);
} catch (Exception $e) {
return $e->getCode();
}
}