> I authenticate with twitter oauth using a popup from 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
> the popup.

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 the popup automatically, 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
> the popup manually 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
> popup without 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


Reply via email to