Hello all,
I am attempting to add Friend Connect into one of my applications.
However, I repeatedly get the same error about relays not being set. I
Googled for a while, but I found nothing relevant. The exact error is
as follows:
"No relay set (used as window.postMessage targetOrigin), cannot send
cross-domain message".
My code is:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /
>
<!-- Load the Google AJAX API Loader -->
<script type="text/javascript" src="
http://www.google.com/jsapi"></
script>
<!-- Load the Google Friend Connect javascript library. -->
<script type="text/javascript">
google.load('friendconnect', '0.8');
</script>
<!-- Initialize the Google Friend Connect OpenSocial API. -->
<script type="text/javascript">
google.friendconnect.container.setParentUrl('/' /* location of
rpc_relay.html and canvas.html */);
google.friendconnect.container.initOpenSocialApi({
site: '15589038843889558124',
onload: function(securityToken) { /* your callback, which is passed
a security token */ initAllData()}
});
</script>
<script type="text/javascript">
window.onload = function() {
google.friendconnect.renderSignInButton({id:"button"})
}
function setupData(data) {
//google.friendconnect.container.setParentUrl("./");
console.log(data)
/* if (!data.errorMessage) {
var site_friends = data.get("viewer_friends").getData();
var list = document.getElementById("friends-list");
list.innerHTML = "";
site_friends.each(function(friend) {
list.innerHTML += "<li>" + friend.getDisplayName() + "</li>";
});
}*/
};
function initAllData() {
var params = {};
params[opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS] =
['profileExtensions'];
var req = opensocial.newDataRequest();
req.add(req.newFetchPersonRequest('VIEWER', params), 'viewer');
req.add(req.newFetchPersonRequest('OWNER', params), 'owner');
req.send(setupData);
}
function saveData(key, val) {
var req = opensocial.newDataRequest();
req.add(
req.newUpdatePersonAppDataRequest("VIEWER", key, val),
"set_data");
req.send(saveCallback);
}
function saveCallback(data) {
console.log(data);
}
function readData(key) {
var idspec = opensocial.newIdSpec({ "userId" : "VIEWER", "groupId" :
"SELF" });
var req = opensocial.newDataRequest();
req.add(
req.newFetchPersonAppDataRequest(idspec, key),
"get_data");
req.send(readCallback);
}
function readCallback(data) {
console.log(data);
}
saveData("test1", "Hello, world!");
readData("test1");
</script>
</head>
<body>
<div id="button"></div>
</body>
</html>
Any idea what this could be?
Cheers,
G3n3r0