我正在尝试开发一个通过Gmail API发送电子邮件的网络应用程序。但是我收到了这个错误:
调用未定义的方法Google_Service_Gmail_Message :: toSimpleObject()
这是我的代码:
// LOAD GOOGLE LIBRARY
$this->CI->load->library('master_google');
$this->CI->load->library('master_phpmailer');
$client = $this->CI->master_google->getClient($data);
$mail = $this->CI->master_phpmailer;
$mail->setFrom($data->sender_email, $data->sender_name);
$mail->addReplyTo($data->response_email, $data->response_name);
$mail->addAddress($data->email);
$mail->Subject = $data->subject;
$mail->msgHTML(htmlspecialchars_decode($data->body));
$mail->preSend();
$mime = $mail->getSentMIMEMessage();
$encoded_message = base64url_encode($mime);
// Gmail Message Body
**$message = new Google_Service_Gmail_Message();**
$message->setRaw($encoded_message);
// Send the Email
$service = new Google_Service_Gmail($client);
$email = $service->users_messages->send('me',$message);
if($email->getId()){
return array('stat' => true, 'msg' => '');
} else {
return array('stat' => false, 'msg' => '');
}
在此行上生成错误:
$ message = new Google_Service_Gmail_Message();
任何帮助表示赞赏。
我找到了什么问题大声笑,我有一个同名的模型:Google_model,我将其重命名为Mygoogle_model,它的工作原理:D
我认为你的toSimpleObject()
课程中不存在gmail-api
方法。