On Oct 26, 9:34 pm, Chris Babcock <cbabc...@kolonelpanic.org> wrote:
> > I authenticate with twitter oauth using apopupfrom my site. When the
> > authentication is done, twitter redirects the user to my site again.
> > The user then has my site both in the original browser window, and in
> > thepopup.
>
> One way of formulating your problem would be "How can I avoid having two
> windows open?" The simplest answer would be, "Don't open a second
> window."
>
> > I want to close thepopupautomatically, so the user don't have to. I
> > do this with the following:
> > <?php if (strlen($_GET['oauth_token']) > 0) { echo "<script>self.close
> > ()</script>"; } ?
>
> > The problem is that when using the above code, the authentication
> > don't seem to work. When trying to tweet I get this:
> > /statuses/update.xml Could not authenticate you.
>
> > When I don't use the above code, and thereby force the user to close
> > thepopupmanually if he don't want it open, everything works fine.
>
> > Can someone explain this to me, and help with how I can auto close the
> >popupwithout messing with the authentication?
>
> PHP is not my language of choice, but that looks like a scoping issue.
>
> When you close the window with JavaScript, the authentication data you
> obtained is lost when the window containing it is closed. You need to
> persist the data whatever that means for your application - save a
> cookie, submit data or (Ugh!) set a global - before you close the
> window
>
> Chris Babcock

Thanks for your tips Chris.

The thing is that the session variables are saved. I'm using Abrahams
oauth script (http://twitter.abrah.am/) and when I check against the
$_SESSION['oauth_state'], it tells me I'm still logged in (I have
connected the visibility of the "post to twitter" form to this
variable, which I only see when I'm logged in, and it works as
intended).

An addition to the previous description. When I don't use the script,
but close the popup manually, I can still post to twitter in chrome
and firefox. I can however not post in internet explorer, there I get
the message "/statuses/update.xml Could not authenticate you". In all
three browsers $_SESSION['oauth_state'] indicate that I'm in fact are
logged in.

What can be different in this scenario between using chrome/firefox or
ie?

Thanks

Reply via email to