예정된 시간에 초안 이메일 (Gmail)을 보내야합니다. 아래 코드를 시도했습니다. Gmail API PHP 클라이언트 라이브러리 또는 API - Gmail 초안을 어떻게 보내나요?
$access_token = 'ya29.DxswidlwadllsidVeg5B67CdpLN6QR0d1nCuQmg9GaMT9iq8-zIA8O29yR9rEMM';
//the access token is subject to change every hour
$header = array('Content-Type: message/rfc822', "Authorization: Bearer $access_token");
$to = '125699645855239833'; // this is a draft id.
$line = "\r\n";
$raw='';
$url = 'https://www.googleapis.com/upload/gmail/v1/users/me/drafts?fields=id&key=XsqwwosqldwwdssaOLwotWD6seRloXZM';
$raw .= "id: $to ".$line.$line;
$method_type = 1; // set as post method
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_HEADER, 0);
if($header !== 0){
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
}
if($method_type == 1 or $method_type == 0){
curl_setopt($curl, CURLOPT_POST, $method_type);
}else{
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
}
if($data !== 0){
curl_setopt($curl, CURLOPT_POSTFIELDS, $raw);
}
$response = curl_exec($curl);
$json = json_decode($response, true);
print_r($json);
curl_close($curl);
내가 설정되지 않은
배열 ([ID] => R-5083530165761240787)하지만 초안 (이메일) 아래로 컬 게시 한 후 결과를 얻었다. 변경 (1)을 다음과 같은
나를 위해 작동합니다. :) –