Search
 
SCRIPT & CODE EXAMPLE
 

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);
      }
   }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: __v:0 in my data mongoose 
Javascript :: mongoose undo delete 
Javascript :: javascript promise multi function error 
Javascript :: returns string of names, seperated by commas and an ampersand namesObj in javascript 
Javascript :: make a table of data from db in jsp 
Javascript :: composer json schema download 
Javascript :: jstree get not disabled nodes 
Javascript :: remove post via ajax 
Javascript :: how to get second low value in js 
Javascript :: react clikc with ref 
Javascript :: login_page-jwt-auth-using-react-and-flask 
Javascript :: what is fn extend 
Javascript :: how to call javascript function in p tag 
Javascript :: formulaire sauvegarde local storage jquery 
Javascript :: javascript synchronous and asynchronous list 
Javascript :: "json" is not defined 
Javascript :: Get even numbers with VanillaJS 
Javascript :: react-native-modal big border 
Javascript :: How to Compare Strings Using localeCompare 
Javascript :: wind in mongoose 
Javascript :: react extends component App.defaultProps 
Javascript :: sum properties some objects when merge their 
Javascript :: Backbone Sync And Fetch Example 
Javascript :: How to Solve the Staircase Problem with JavaScript using Memoization 
Javascript :: pro side nav react rtl 
Javascript :: Register Multiple Models In Admin 
Javascript :: load image file input jquery 
Javascript :: regex from 5 to 30 1 number 1 lower case and 1 upper case letter 
Javascript :: Include Path reactjs in VS code in in urud 
Javascript :: copy text input javascript 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =