Скрипт приложения Google Создать контакт
function test() {
createContact('Test Contact', '08273488734', '');
}
function doGet( req ) {
const { action, ...data } = req.parameter;
switch(action) {
case "create":
const { name, phone, email } = data;
createContact( name, phone, email );
return response().json({
sucess: true,
message: 'Berhasil menyimpan kontak ke Google Contacts'
});
break;
default:
break;
}
}
function createContact(name, phone, email) {
const contact = ContactsApp.createContact(name, '', '');
contact.setMobilePhone(phone);
if (email) contact.setPrimaryEmail(email);
const group = ContactsApp.getContactGroup('System Group: My Contacts');
group.addContact(contact);
return contact;
}
function response() {
return {
json: function(data) {
return ContentService
.createTextOutput(JSON.stringify(data))
.setMimeType(ContentService.MimeType.JSON);
}
}
}
BuatanID