开发者

Google Friend Connect fcauth cookie in php

this may be easy for most of you .. but not me.

I am using some "sample" Google code - as it fits my purpose so why change what works - but for the life of me I cannot access/find/get etc the FCAuth cookie after a user is logged in.

Help please - thanks in advance.

Here is my code (the Site ID is in a set variable, and all the calls work todate. just need to find/get the FCAuth cookie.

    var viewer, ownerFriends, activities;
google.friendconnect.container.setParentUrl('/api/' /* location of rpc_relay.html and canvas.html */);
google.friendconnect.container.loadOpenSocialApi({ 
site: SITE_ID,
onload: function() { initAllData(); }});

function initAllData() {
  var params = {};
  params[opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS] =
    [opensocial.Person.Field.ID,opensocial.Person.Field.NAME,opensocial.Person.Field.THUMBNAIL_URL,opensocial.Person.Field.PROFILE_URL];
  var req = opensocial.newDataRequest();
  req.add(req.newFetchPersonRequest('VIEWER', params), 'viewer');
  req.add(req.newFetchPeopleRequest(

   new opensocial.IdSpec({'userId' : 'OWNER', 'groupId' : 'FRIENDS'}), params), 
    'ownerFriends');
  req.add(req.newFetchActivitiesRequest(new opensocial.IdSpec({'userId' : 'OWNER', 'groupId' : 'FRIENDS'})), 'activities');

  var idspec = new opensocial.IdSpec({ 'userId' : 'VIEWER','groupId' : 'FRIENDS' });
  req.add(req.newFetchPeopleRequest(idspec), 'viewer_friends');
  req.send(onData);
  req.send(setupData);

};

function setupData(data) {
  ownerFriends = data.get('ownerFriends').getData().asArray();
  var html = "";
  for (var i = 0; i < ownerFriends.length && i < 8; i++) {
    var person = ownerFriends[i];
    html += "<a title='" + person.getField("displayName") + "' href='" + person.getField("profileU开发者_如何学编程rl") + "'>";
    html += "<img class='memberPhoto' src='" + person.getField("thumbnailUrl")  + "' width='50px' alt='" + person.getField("displayName") + "'/>";
    html += "</a>&nbsp;&nbsp;";
  };

  document.getElementById('members').innerHTML = html;

  viewer = data.get('viewer').getData();
  if (viewer) {
    document.getElementById('memberstate').innerHTML = 
    '<h2>' + viewer.getField("displayName") + ' welcome to the Yoga Council of Canada </h2>' ;
  } else {
    document.getElementById('memberstate').innerHTML = 
    '<h2>Join with one click</h2> After joining, you will automatically appear as a recent member.';
  }

  viewer = data.get('viewer').getData();
  if (viewer) {
    document.getElementById('profile').innerHTML = 
    '<img align="left" src="' + viewer.getField("thumbnailUrl")  + '" style="margin-right: 20px;" >' +
    '<strong>' +  viewer.getField("displayName") + '</strong><br>' +
    '<a href="#" onclick="google.friendconnect.requestSettings(); return false;">Settings</a><br>' +
    '<a href="#" onclick="google.friendconnect.requestInvite(\'Come and join the Yoga Council of Canada \'); return false;">Invite a friend</a><br>' +
    '<a href="#" onclick="google.friendconnect.requestSignOut(); return false;">Sign out</a><br>';
  } else {
    google.friendconnect.renderSignInButton({ 'id': 'profile' });
  }

};

function onData(data) {
if (!data.get("viewer_friends").hadError()) {
  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>";
  });
}

};


OK, I am/was being totally thick, the cookie is automatically set as

$_COOKIE['fcauth<your appID>'];

So you can "just call it" i.e.

<?php if($_COOKIE['fcauth<your appID>']): do something endif; ?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜