Google Friend Connect fcauth cookie в php - PullRequest
       4

Google Friend Connect fcauth cookie в php

0 голосов
/ 26 августа 2010

это может быть легко для большинства из вас ... но не для меня.

Я использую некоторый "образец" кода Google - так как он соответствует моей цели, так зачем менять то, что работает - но для моей жизниЯ не могу получить доступ / найти / получить и т. Д. Файл cookie FCAuth после того, как пользователь вошел в систему.

Помогите пожалуйста - заранее спасибо.

Вот мой код (идентификатор сайта находится в переменной набора, и все вызовы работают в настоящее время. просто нужно найти / получить файл cookie FCAuth.

    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 голосов
/ 30 августа 2010

ОК, я / был полностью толстым, cookie автоматически устанавливается как

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

Так что вы можете «просто позвонить», то есть

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