How can I manage Google account's contacts through JavaScript?

*爱你&永不变心* 提交于 2019-11-30 19:20:03

问题


I'm trying to manage Google account contacts through JavaScript programs. When I'm trying to delete contacts through JavaScript, this error occurs: "Network Error: 405 Not Allowed Method."

Here is My Code:

function deleteContacts() {
    $.ajax({
        type: 'DELETE',
        url: 'https://www.google.com/m8/feeds/contacts/default/full/{client_Id}?access_token=' + tokenId,
        headers: {
            'If-Match': '*',
            'Gdata-version': '3.0'
        },
        dataType: 'jsonp',
        data: {},
        success: function (data) {
            console.log("response: " + data)
        }
    });
}

Please help me in this, is this possible to manage Google account's contacts through JavaScript? If it is really possible then please tell me all possibilities for managing Google account's contacts....

Is there any other JavaScript API available?


Is there any alternate solution?


I Know Google has listed solutions in java, PHP, nodes as well, and I am writing server code in Nodejs, but seems like Google client code for NodeJs in alpha version, not sure how much strong it is to manage contacts...


回答1:


Make use of the google client api for javascript, Authenticate, getToken and then use Request and then execute it. Pass on the method and url as per your need. For delete purpose, pass these are its input:

 method : 'DELETE',
 url : '/m8/feeds/contacts/default/full/<friend id to delete>'    


来源:https://stackoverflow.com/questions/19762065/how-can-i-manage-google-accounts-contacts-through-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!