我正在使用带有PHP的Gmail API并尝试获取检索到的线程的所有附件,但如果我为超过1.3 MB的附件设置了限制大小,我的代码会返回一个没有内容和状态代码200的空白页。我将附件保存为base64编码的字符串以替换所有嵌入的图像和附件。
Push Notifications
但是,如果大小小于1.5 mb,我的脚本就可以了。
//some code before
//for attachments in latest message in a thread
if(isset($data['threads'][$keyT][$keyA]['attachments'])){
$attachments=$data['threads'][$keyT][$keyA]['attachments'];
for($i=0;$i<count($attachments);$i++){
$a=$attachments[$i];
if(
(
$a['mimetype']=='image/gif' ||
$a['mimetype']=='image/jpeg' ||
$a['mimetype']=='image/pjpeg' ||
$a['mimetype']=='image/png' ||
$a['mimetype']=='image/svg+xml'
) && $a['size']<1500000
){
$data['threads'][$keyT][$keyA]['attachments'][$i]['data']=$this->getAttachmentInner(
$data['threads'][$keyT][$keyA]['attachments'][$i]['attachmentId'],$data['threads'][$keyT][$keyA]['gmailmsgid'],
$detail['redirect_url'],$detail['app_name'],$detail['secret'],$detail['credentials']
);
}else{
echo "<pre>";
print_r($a);
echo "</pre>";
}
}
}
// for embed images
for ($k=0;$k<count($data['threads']);$k++){
for($j=0;$j<count($data['threads'][$k]);$j++){
if(isset($data['threads'][$k][$j]['attachments'])){
$attachments=$data['threads'][$k][$j]['attachments'];
for($i=0;$i<count($attachments);$i++){
$a=$attachments[$i];
if(
(
$a['mimetype']=='image/gif' ||
$a['mimetype']=='image/jpeg' ||
$a['mimetype']=='image/pjpeg' ||
$a['mimetype']=='image/png' ||
$a['mimetype']=='image/svg+xml'
) && $a['size']<1500000 && $a['class']=='embed' && isset($a['embed_id'])
){
$data['threads'][$k][$j]['attachments'][$i]['data']=$this->getAttachmentInner(
$data['threads'][$k][$j]['attachments'][$i]['attachmentId'],$data['threads'][$k][$j]['gmailmsgid'],
$detail['redirect_url'],$detail['app_name'],$detail['secret'],$detail['credentials']
);
}else{
}
}
}
}
}
我也有PHP的这些设置,但他们没有帮助:
&& $a['size']<500000