Friday, 1 February 2019

Add to Contacts like Add to Calendar button/ html/ Ajax option

I would like to develop a "Add to contacts" button for a webpage, much like the "add to calendar - Google, ICal, Outlook" type buttons that you see on webinar and event pages like this one.

I started investigating Google Contacts, as I use that. I started building a form to submit an application/atom+xml to the URL they talk about in the help files here and a similar question for Google on Stack.

I figure creating this is a Open Source like service to the community, some expert help would be appreciated as I tinker with it. I am asking here for that contribution.

My rough code, that isn't working






function SendToGoogle() {

var url = "https://www.google.com/m8/feeds/contacts/default/full";
var data = contactData();

alert(data);

/*
$.post(url, data, function(data, status){
        alert("Data: " + data + "\nStatus: " + status);
    });
*/
    $.ajax({type: "POST",
        url: url,
        dataType: "xml",
        contentType: "application/atom+xml",
        cache: false,
        async: true,
        crossDomain: true,
        success: function(data, status){
        alert("Data: " + data + "\nStatus: " + status)}
})


} //end SendToGoogle








function contactData() {
return '        Elizabeth     Bennet     Elizabeth Bennet    Notes          (206)555-1212        (206)555-1213          Mountain View    1600 Amphitheatre Pkwy    CA    94043    United States          1600 Amphitheatre Pkwy Mountain View    ';
} //end contactData





from Add to Contacts like Add to Calendar button/ html/ Ajax option

No comments:

Post a Comment