Issue in retrieving contacts data through Contact Data API.

130 views
Skip to first unread message

Brijesh Shah

unread,
Oct 20, 2008, 5:06:41 AM10/20/08
to Google Contacts API, info...@gmail.com
Hi

I wrote a code to retrieve contacts data through Contact Data API.
I got authentication token but I was getting error "An Image of same
domain is required on this page for authenticated reads and writes"

Can anyone explain what exactly this error saying?

written code as below

<script type="text/javascript" src="http://www.google.com/jsapi"></
script>
<script>

google.load("gdata", "1.x");
google.setOnLoadCallback(initFunc);
var contactsService;

function setupContactsService() {
contactsService = new
google.gdata.contacts.ContactsService('exampleCo-exampleApp-1.0');
}

function logMeIn() {
var scope = 'http://www.google.com/m8/feeds';
var token = '<?php echo $_REQUEST[token]; ?>';//'CJ_clo6oHxDpvvb-
BA';//google.accounts.user.login(scope);
}
function initFunc() {
setupContactsService();
logMeIn();
getMyContacts();
}
function handleError(e) {
alert("There was an error!");
alert(e.cause ? e.cause.statusText : e.message);
}

function getMyContacts() {
var contactsFeedUri = 'http://www.google.com/m8/feeds/contacts/
brijesh....@gmail.com/full';
var query = new google.gdata.contacts.ContactQuery(contactsFeedUri);

// Set the maximum of the result set to be 5
query.setMaxResults(5);

contactsService.getContactFeed(query, handleContactsFeed,
handleError);
}

var handleContactsFeed = function(result) {

var entries = result.feed.entry;

for (var i = 0; i < entries.length; i++) {
var contactEntry = entries[i];
var emailAddresses = contactEntry.getEmailAddresses();

for (var j = 0; j < emailAddresses.length; j++) {
var emailAddress = emailAddresses[j].getAddress();
alert('email = ' + emailAddress);
}
}
}
</script>


<?
$_SESSION[token]=$_REQUEST[token];
echo $_SESSION[token];
?>

<button onClick="getMyContacts()" value="Click Here" > Click Here</
button>

Trevor Johns

unread,
Oct 20, 2008, 7:37:23 PM10/20/08
to google-co...@googlegroups.com, info...@gmail.com
On Mon, Oct 20, 2008 at 2:06 AM, Brijesh Shah
<brijesh....@gmail.com> wrote:
>
> Hi
>
> I wrote a code to retrieve contacts data through Contact Data API.
> I got authentication token but I was getting error "An Image of same
> domain is required on this page for authenticated reads and writes"

It means that your page needs to have at least one image (<img
src="..." />) that's hosted off of your domain. It doesn't matter
what, there just needs to be at least one image.

It's a strange requirement, but that's part of the mechanism we use to
bypass the same-origin policy.

--
Trevor Johns

Reply all
Reply to author
Forward
0 new messages