Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Membuat contact di google contact dengan google app script, sync ke android.

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);
      }
   }
}
Source by gist.github.com #
 
PREVIOUS NEXT
Tagged: #Membuat #contact #di #google #contact #dengan #google #app #sync #ke
ADD COMMENT
Topic
Name
2+7 =