我正在使用Codeigniter框架,并试图与SendInBlue的PHP集成。他们的PHP文档不是超级有用的,Github上的设置说明也不清楚。
医生说“下载文件并包含autoload.php":
require_once('/path/to/APIv3-php-library/vendor/autoload.php');但是我在任何地方都找不到autoload,我也不知道如何将它包含在CI结构中。
更新:
我联系了Sendinblue支持,他们没有任何针对CI用户的安装教程。我尝试使用Compiler,并创建了文件夹结构,但我仍然存在将其与CI集成的问题。我把所有的文件夹放在我的库中,但是它没有正确加载,并且抱怨Autoload类不存在。

发布于 2018-07-30 11:06:58
要获得autoload.php,您需要使用作曲家。这将解决所有依赖项,并为您安装/更新它们。
如果库位置中已有整个SendInBlue API文件夹结构,则只能在class My_Class ... line require_once (APPPATH . 'vendor/autoload.php');之前添加控制器。
例如:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
// include manually module library - SendInBlue API
require_once (APPPATH . 'vendor/autoload.php');
class My_Class extends CI_Controller {
....之后,您可以按照Github: APIv3 3-php-库-入门的指南进行操作。
如果出现错误,就意味着SendInBlue的结构很糟糕。我建议你使用作曲家
autoload.php -参见前面的示例如果您还有问题,请在这里添加错误列表。
发布于 2021-01-28 13:42:33
我有一个很好的解决方案,这对我来说很好,我希望它也能对你有用。我使用的是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();
}
}https://stackoverflow.com/questions/51012680
复制相似问题