Yii Framework Forum: Question on 'logged in" state with facebook-opengraph extension - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Question on 'logged in" state with facebook-opengraph extension Rate Topic: -----

#1 User is offline   michaellyseng 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 05-June 12

Posted 05 June 2012 - 06:16 PM

Hi all,

I'm posting this on behalf of a colleague who ran out of time today, so bear with me. I'm not involved in his development right now, so I'll do my best to ask this question without looking like a fool.

The question is essentially framed in the topic. He's trying to implement Facebook registration and login for our Yii app and is essentially trying to find a "is the user logged in" method.

Can anyone who's used this extension (http://www.yiiframew...book-opengraph/) offer any insight? If I understand him correctly he gets all the user data when it's invoked, but is unable to determine if the user is logged in or not. Does that make any sense? I will chat with him later to get more info, but based on what I've just said, if anyone has a suggestion or approach we'd sure appreciate it.

Thanks!
Michael
0

#2 User is offline   Sampa 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 173
  • Joined: 18-December 11
  • Location:Stockholm,Sweden

Posted 06 June 2012 - 03:52 AM

there is YiiAuth to try
http://www.yiiframew...490#entry156490


For that extension you linked to I also have a working demo
http://www.yiiframew...016#entry152016

If only facebook is interesting I would recommend the last link, but if you want more like twitter,openid etc etc the first is by far a better options.
0

#3 User is offline   autoboxer 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 06-June 12

Posted 06 June 2012 - 10:11 AM

Colleague here to clarify the problem...

I have downloaded the Yii facebook-opengraph extension located here: http://www.yiiframew...book-opengraph/

From what I can tell I have implemented the LoginButton correctly. After authenticating with Facebook (with the Facebook modal login), the login button updates through ajax and shows that I am logged in by displaying my Facebook image icon.

However, my problem is that I can not find a property that indicates that I am logged in on Facebook. This seems so trivial and it is probably something I am overlooking. When not logged in, I expected I could call
Yii::app()->facebook->getUser()
and the return value would be null or 0, but it is not... it is still displaying my last logged in Facebook user id. Somehow it seems this value is caching.

Is there any idea on how to fix this?

0

#4 User is offline   autoboxer 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 06-June 12

Posted 06 June 2012 - 10:26 AM

It looks like I've answered my own question minutes after posting. :) Hopefully this may help others, or perhaps someone has another helpful answer.

I noticed when the user was not logged into Facebook, calling
Yii::app()->facebook->getInfo()
would throw an exception. So I have used this in conjunction with destroying the session to fix my problem. See below.

try {
  	$userinfo = Yii::app()->facebook->getInfo();	
  } catch (Exception $e) {
  	Yii::app()->facebook->destroySession();
  }

echo Yii::app()->facebook->getUser(); // this is now equal to 0 if not logged into Facebook 



I still think it would be nice to have the following code implemented:

Yii::app()->facebook->isLoggedIn(); // boolean indicating whether user was logged into Facebook account


Thanks and hopefully someone may find this useful.
0

#5 User is offline   Sampa 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 173
  • Joined: 18-December 11
  • Location:Stockholm,Sweden

Posted 06 June 2012 - 01:18 PM

Why it returns a old userid is probably because u are still logged into facebook, i noticed some times I had to visit facebook.com and logout , some major problems overall.

I would still recommend hybridauth.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users