<html> | |
<head> | |
<script src="https://apis.google.com/js/client.js"></script> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> | |
<script> | |
function auth() { | |
var config = { | |
'client_id': 'OAUTH_CLIENT_ID', | |
'scope': 'https://www.google.com/m8/feeds' | |
}; | |
gapi.auth.authorize(config, function() { | |
fetch(gapi.auth.getToken()); | |
}); | |
} | |
function fetch(token) { | |
$.ajax({ | |
url: 'https://www.google.com/m8/feeds/contacts/default/full?alt=json', | |
dataType: 'jsonp', | |
data: token | |
}).done(function(data) { | |
console.log(JSON.stringify(data)); | |
}); | |
} | |
</script> | |
</head> | |
<body> | |
<button onclick="auth();">GET CONTACTS FEED</button> | |
</body> | |
</html> |
This comment has been minimized.
This comment has been minimized.
the above fetch function gives same origin policy error. here is the code which will solve this problem.
|
This comment has been minimized.
This comment has been minimized.
I get this error |
This comment has been minimized.
This comment has been minimized.
Thanks, works perfectly. |
This comment has been minimized.
This comment has been minimized.
@hemank-s How would one configure that for localhost? |
This comment has been minimized.
This comment has been minimized.
@crutchcorn, create a local http server. |
This comment has been minimized.
This comment has been minimized.
I got this error can any body please help me to fix this issue. |
This comment has been minimized.
This comment has been minimized.
@bhupeshpant19jan I know how to run a local webserver. :D I was wondering how to configure the redirect ui in google dev console |
This comment has been minimized.
This comment has been minimized.
console.log(JSON.stringify(data)); return bunch of data could you please suggest me how to grab one by one email using loop or any other methods thanks. |
This comment has been minimized.
This comment has been minimized.
i am using the subdomain in rails. so every time My origin url is different. because i have many subdomains. i m using the lvh.me:3000. local server. how can i set the origin url.. which support every time in any subdomain..?? |
This comment has been minimized.
This comment has been minimized.
hi, i have some question i tried to fetch google mail contact through Google_Http_Request and it works fine but still i'm encountering some problem, there is some contact that i added/create api as well and it shows to the google contact in may mail web gmail, but when i'm fetching it all thru api again some emails are missing but still it is visible on the google contact web server. is there anyone know this scenario? |
This comment has been minimized.
This comment has been minimized.
I am getting this error Error: Permission denied to access property 'nodeType' |
This comment has been minimized.
This comment has been minimized.
@loganathan-s: you might want to take a look at this post on stackoverflow
so just change the fetch function of the example on the top to
|
This comment has been minimized.
This comment has been minimized.
It is simple and works very well, but .... Does anyone have an idea why you see only a part of the contacts and not all ??? |
This comment has been minimized.
This comment has been minimized.
Really useful. I have checked the documentation of Google Contacts API for javascript but I couldn't find nothing related to create new Contacts. Thanks in advance. |
This comment has been minimized.
This comment has been minimized.
this was very helpful but i want to access individual email address from contacts and display in web page. please help with the code. |
This comment has been minimized.
This comment has been minimized.
@ClaudioLoano, you need to pass the max-results query parameter. Probably increase it to 2000 |
This comment has been minimized.
This comment has been minimized.
hi @Ganesh-tresbu, Could you solve the problem? |
This comment has been minimized.
This comment has been minimized.
Hi, I want to retrieve all contacts from my Gmail account. So am using the url as "https://www.google.com/m8/feeds/contacts/{userEmail}/full". But the returned results is for only 25 contacts. Can anyone help me. |
This comment has been minimized.
This comment has been minimized.
@Mani0702 you should add a query parameter called 'max-results', into the URL |
This comment has been minimized.
This comment has been minimized.
Hi All, Was trying to use this api in react js And when clicked on these error it takes me to the line: fetch(gapi.auth.getToken()); I guess am not getting gapi object in these component as its the script file : client.js which gets the gapi stuffs is in my index file. Please guide guys. Immediate help will be totally appreciated. Thanks in advance |
This comment has been minimized.
This comment has been minimized.
After freshly pasting this into a HTML file and adding my client id, I'm getting this error: "Uncaught DOMException: Blocked a frame with origin "http://localhost:8080" from accessing a cross-origin frame." |
This comment has been minimized.
This comment has been minimized.
I have done the googles contact api credential part while i'm running the above code i still got error 401. will you please help me to resolve this. |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
Working fine but how to get all record right now i am getting only 25 result at a time. |
This comment has been minimized.
This comment has been minimized.
is there a way where i can get contacts on a page load if already signed in with google? |
This comment has been minimized.
This comment has been minimized.
All the contacts are retrieved with email,name and id but not able to get Phone number. Used tag gd:phoneNumber but failed to retrieve. Can you help please |
This comment has been minimized.
This comment has been minimized.
Hello guys, Thank you for this code, it works very well for me and i was able to fetch all my google contacts. Do you know if I can do something about it ? Thank you very much again guys :) |
This comment has been minimized.
This comment has been minimized.
This works perfect for quite a long time, but starting last week I'm getting the error msg of |
This comment has been minimized.
This comment has been minimized.
Replacing |
This comment has been minimized.
works perfectly, thanks! except that I'm running into a same origin policy error. Any suggestions?