我試圖開發一個通過Gmail API發送電子郵件的Web應用程序。 但我發現了這個錯誤:調用未定義的方法Google_Service_Gmail_Message :: toSimpleObject()
調用未定義的方法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.php,它應自動列入引起它是Google API的一部分。 – Domenic