Be sure to use the newest PHP SDK v3.1.1 and if incorporating social plugins
to your site also be sure to use the Javascript SDK in conjunction with the
PHP SDK.
Try moving your code into the beforeFilter() of your controller:
function beforeFilter(){
parent::beforeFilter();
if (!$this->facebook->getUser()){
$loginUrl = $this->facebook->getLoginUrl(array(
'scope' =>
'publish_stream',
'fbconnect' => 0,
'next' =>'
http://localhost/to_do_list/users/index'<http://localhost/to_do_list/users/index')>
,
'cancel' => //
Cancel url
'canvas' => 1
)
);
echo "<script type='text/javascript'>top.location.href =
'$loginUrl';</script>";
}
}
On Wed, Oct 12, 2011 at 3:34 PM, Kyle <[email protected]> wrote:
> It won't load the actual index page because there is no user, it just
> keeps sending it back to facebook.
>
> function index() {
> $this->set('user_id', $this->facebook->getUser());
> if ($this->user_id == 0) {
> $login_url = $this->facebook->getLoginUrl(array(
> 'scope' => 'publish_stream',
> 'redirect_uri' => '
> http://localhost/to_do_list/users/index'));
> echo "<script
> type='text/javascript'>top.location.href =
> '$login_url';</script>";
> }
> }
>
> If I put a link to the login_url on the index page instead of trying
> to do it automatically it will get the user.
>
> On Oct 12, 2:07 pm, Ed Propsner <[email protected]> wrote:
> > Out of curiosity .... when Facebook redirects back to
> > http:://localhost/app/users/index if you refresh the page at that point
> is
> > $this->facebook->getUser() now available?
> >
> >
> >
> >
> >
> >
> >
> > On Wed, Oct 12, 2011 at 1:12 PM, Kyle <[email protected]> wrote:
> > > I'm new to all of this, php/cakephp/facebook. I'm trying to create a
> > > facebook app but ran into a problem with authentication that I can't
> > > figure out. I'm using the facebook php-sdk, after I send the user to
> > > the facebook loginurl they come back to the page but I still can't get
> > > the fb user. If I set the loginurl redirect_uri to a different page
> > > like users/home then I can get the fb user and everything works fine,
> > > however I want them to come back to the same page.
> >
> > > This will not get a user:
> > > $login_url = $this->facebook->getLoginUrl(array(
> > > 'scope' => 'publish_stream', 'redirect_uri' => '
> > >http://localhost/app/
> > > users/index'));
> > > echo "<script type='text/javascript'>top.location.href =
> > > '$login_url';</script>";
> >
> > > This will:
> > > $login_url = $this->facebook->getLoginUrl(array(
> > > 'scope' => 'publish_stream', 'redirect_uri' => '
> > >http://localhost/app/
> > > users/home'));
> > > echo "<script type='text/javascript'>top.location.href =
> > > '$login_url';</script>";
> >
> > > --
> > > Our newest site for the community: CakePHP Video Tutorials
> > >http://tv.cakephp.org
> > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
> > > others with their CakePHP related questions.
> >
> > > To unsubscribe from this group, send email to
> > > [email protected] For more options, visit this
> group
> > > athttp://groups.google.com/group/cake-php
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group
> at http://groups.google.com/group/cake-php
>
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php