[edit]
This is not a how-to; I'd originally posted this tagged as a question, and now don't see a way to fix it back. It is a "how to get your google contacts that have phones listed into a file on google drive and how to share that file. It is not a way to import that file's contents into Asteridex. That's why it was a question. Sorry for any confusion.
[/edit]
I've been looking for a way to synchronize Asteridex and Google Contacts; just one way Google to Asteridex, and only the contacts that have at least one phone number.
I've written Google Script to parse through all contacts, and list the ones with phone numbers in a CSV file on Google Drive.
Google scripts can be set to run periodically, and files on Google Drive can be shared, in that you then have a URL pointing to the file.
I have not written, but can write, another script that just lists new/changed contacts.
So... now I'm looking for some kind of howto for importing contacts into Asteridex. It's in MySQL? Anyone have an import/export cmd line script I might look at? I'm new to this and am not even really sure how to use Asteridex.
Thanks!
BTW, current iteration of that script appended below. To use, go to https://script.google.com , select "Create Blank Project" and paste it in. "Save", then "Run", pick 'main' (you'll need to do this twice, first time gets all the permissions needed).
To make the CSV file available, go to Google Drive, right-click the file, pick 'Share", you'll get a popup with the URI.
This is not a how-to; I'd originally posted this tagged as a question, and now don't see a way to fix it back. It is a "how to get your google contacts that have phones listed into a file on google drive and how to share that file. It is not a way to import that file's contents into Asteridex. That's why it was a question. Sorry for any confusion.
[/edit]
I've been looking for a way to synchronize Asteridex and Google Contacts; just one way Google to Asteridex, and only the contacts that have at least one phone number.
I've written Google Script to parse through all contacts, and list the ones with phone numbers in a CSV file on Google Drive.
Google scripts can be set to run periodically, and files on Google Drive can be shared, in that you then have a URL pointing to the file.
I have not written, but can write, another script that just lists new/changed contacts.
So... now I'm looking for some kind of howto for importing contacts into Asteridex. It's in MySQL? Anyone have an import/export cmd line script I might look at? I'm new to this and am not even really sure how to use Asteridex.
Thanks!
BTW, current iteration of that script appended below. To use, go to https://script.google.com , select "Create Blank Project" and paste it in. "Save", then "Run", pick 'main' (you'll need to do this twice, first time gets all the permissions needed).
To make the CSV file available, go to Google Drive, right-click the file, pick 'Share", you'll get a popup with the URI.
Code:
function main(){
var filename = 'GooglePhonelist.txt';
var found = DocsList.find(filename);
if( found.length > 0) {
var file = found[0];
} else {
var file = DocsList.createFile(filename,'');
}
file.clear();
var list = getPhoneContactsAsCSV();
file.append(list);
}
function getPhoneContactsAsCSV() {
var header = '"Name","Home Phone","Work Phone","Mobile Phone"\r\n';
var entries = new Array();
// get all contacts
var contacts = ContactsApp.getContacts();
// for each contact
for (var i=0; i<contacts.length; i++){
var contact = contacts[i];
var fullName = contact.getFullName();
// for each phone number
var phones = contact.getPhones();
if(phones.length > 0) {
var homePhone = '';
var workPhone = '';
var mobilePhone = '';
for (var p=0; p<phones.length; p++){
var phoneNum = phones[p].getPhoneNumber();
var label = phones[p].getLabel();
if (label == 'HOME_PHONE') homePhone = '"' + phoneNum + '"';
if (label == 'WORK_PHONE') workPhone = '"' + phoneNum + '"';
if (label == 'MOBILE_PHONE') mobilePhone = '"' + phoneNum + '"';
}
csvline = '"' + fullName + '",' + homePhone + ',' + workPhone + ',' + mobilePhone + '\r\n';
entries.push(csvline);
}
}
entries.sort();
joined = entries.join('');
phoneCSV = header + joined;
return(phoneCSV);
}
// APIs used:
// https://developers.google.com/apps-script/reference/docs-list/file
// https://developers.google.com/apps-script/reference/contacts/