我正在尝试在我的项目中不使用composer安装SendGrid,只是直接从SendGrid PHP项目zip包中安装,就像他们在这里说的那样:https://github.com/sendgrid/sendgrid-php
所以我解压缩了文件夹sendgrid-php.zip并将此文件夹放在lib文件夹中。 文件夹结构如下所示:
然后我调用库
require("lib/sendgrid-php/sendgrid-php.php");
我的php脚本中也有这个:
$sendgrid = new SendGrid(SENDGRID_API_KEY);
$email = new SendGrid\Email();
$email
->addTo($to[0]['email'])
->setHtml($body)
->setSubject($subject)
->setFrom($options['from']['email'] )
->setFromName( $options['from']['name'] )
->setCategories($options['tags']);
try {
$sendgrid->send($email);
echo "send: " . $subject . "\n";
} catch(\SendGrid\Exception $e) {
echo $e->getCode();
foreach($e->getErrors() as $er) {
echo $er;
}
}
当我运行项目时,我收到以下错误:
PHP Fatal error: Class 'Guzzle\Http\Client' not found in /private/var/www/job/lib/sendgrid-php/lib/SendGrid.php on line 85
Fatal error: Class 'Guzzle\Http\Client' not found in /private/var/www/job/lib/sendgrid-php/lib/SendGrid.php on line 85
无法弄清楚为什么我收到此错误,Guzzle Http Client类实际上在sendgrid-php文件夹中: