情景:
我使用Gmail API将最近上传的文件的网址发送到谷歌驱动器中。
一切正常。我发送文件的URL如下:
https://drive.google.com/open?id=0B_lb8LUbyw85T0XXXXXXXXXXXX
邮件已发送,但问题是,我在邮件中收到了这样的网址
https://drive.google.com/open?id _lb8LUbyw85T0XXXXXXXXXXXX
所以我认为问题在于我将邮件内容编码为base64。
我在google搜索了很多,但几乎所有的结果都是关于url安全编码的,我可以在url中传递编码字符串。
所以任何人都有解决方案,请告诉我。
提前感谢。
我的Gmail功能:
/* * *******************************
* Send the uploaded file path
* ******************************* */
function SendBackUpFilePath($name, $date, $desc, $path) {
$client = GetGoogleClient();
$service = new Google_Service_Gmail($client);
$raw_message = "To: My Name <maymailid@gmail.com>\r\n";
$raw_message .= 'Subject: =?utf-8?B?' . base64_encode('File backup dated ' . $date) . "?=\r\n";
// Set the right MIME & Content type
$raw_message .= "MIME-Version: 1.0\r\n";
$raw_message .= "Content-Type: text/html; charset=utf-8\r\n";
$raw_message .= 'Content-Transfer-Encoding: quoted-printable' . "\r\n\r\n";
$raw_message .= "<br><br>The file has been backed up for this day [$date]<br><br>Filename : $name";
$raw_message .= "<br><br>Description: $desc<br><br>Link: $path";
$mime = rtrim(strtr(base64_encode($raw_message), '+/', '-_'), '=');
$message = new Google_Service_Gmail_Message();
$message->setRaw($mime);
$result = $service->users_messages->send('me', $message);
$googleMessageId = $result->getId();
echo "Shared Link mailed!";
}