Google朋友在php中连接fcauth cookie

时间:2010-08-26 08:26:49

标签: cookies facebook friend

这对你们大多数人来说可能很容易..但不是我。

我正在使用一些“示例”Google代码 - 因为它符合我的目的,所以为什么要改变它的作用 - 但对于我的生活,我无法在用户登录后访问/查找/获取FCAuth cookie。

请帮助 - 提前致谢。

这是我的代码(站点ID在一个set变量中,并且所有调用都起作用。只需要查找/获取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("profileUrl") + "'>";
    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>";
  });
}

};

1 个答案:

答案 0 :(得分:0)

好的,我/是非常厚,cookie自动设置为

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

所以你可以“只是打电话”,即

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