Skip to content

Instantly share code, notes, and snippets.

@Znack
Created July 12, 2015 09:18
Show Gist options
  • Save Znack/3a10e4207a9bfbaca7f9 to your computer and use it in GitHub Desktop.
Save Znack/3a10e4207a9bfbaca7f9 to your computer and use it in GitHub Desktop.
Import contacts
function importContact (phone, firstName, lastName) {
return MtpApiManager.invokeApi('contacts.importContacts', {
contacts: [{
_: 'inputPhoneContact',
client_id: '1',
phone: phone,
first_name: firstName,
last_name: lastName,
}],
replace: false,
}).then(function (importedContactsResult) {
saveApiUsers(importedContactsResult.users);
var foundUserID = false;
angular.forEach(importedContactsResult.imported, function (importedContact) {
onContactUpdated(foundUserID = importedContact.user_id, true);
});
return foundUserID || false;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment