I am completely baffled by this.
I have a PHP script that is using Cameron Hinkle's
LightweightPicasaAPIv3 to authenticate with the Google Picasa service
using the AuthSub method.
Basically, if we're not authenticated, redirect to the google authsub
URL:
(https://www.google.com/accounts/AuthSubRequest?next=http%3A%2F%2Ftwozerowest.com%2Fsnowdog%2520gallery%2Fadmin.php&scope=http%3A%2F%2Fpicasaweb.google.com%2Fdata%2Ffeed%2Fapi&session=1
)
This page requests that the user either grant access or deny access.
Grant access takes us to the URL specified (my authentication script)
with a ?token=xxxxx added to the end of the URL.
This all works. We get back to my URL with ?token=xxxxx appended to
the URL.
That's when it starts getting weirder than anything I've seen in PHP:
My debugging output confirms that:
1. $_SERVER['request_method'] = GET
2. strlen($_GET['token']) = 0
3. $_GET - array()...but it's empty!
4. $_REQUEST[] contains no 'token' element
5. echo($_GET['token']) prints the value of ?token= from the URL
So WTF?
My code:
Note the comments inside/around the try/catch statement inside the if
block.
WTF? This evaluates to false...or seems to anyway. Code that is inside
it's if{} statement does not execute.
if(strlen($_GET['token']) > 0)
But then, other code that IS in it's if{} statement DOES execute...and
the $_GET['token'] that has a 0 strlen in the if() statement now echos
as a 16 character string!
WTF!!???
if(strlen($_GET['token']) > 0) {
// evaluates ???...
$firephp->info('got a token: ' . $_GET['token']); #this
doesn't happen
echo ('echo $_GET[\'token\'] output: ' . $_GET['token']);
#this doesn't happen
// try to authenticate with it
# this try/catch block DOES NOT happen!
try{
$token = $pic->authorizeWithAuthSub($_GET['token']);
$firephp->info('running authorizeWithAuthSub() with
token: ' . $_GET['token']);
if($pic->isAuthenticated()){
$firephp->info('there we go...authenticated!');
$firephp->info('token :' . $pic->getAuthToken());
echo 'inside try/catch :' . $_GET['token']; #this
echo statement inside the try/catch DOES happen...WTF!?
}
} catch (Picasa_Exception_FailedAuthorizationException $e){
$firephp->log($e, 'error');
}
} else {
$pic->redirectToLoginPage('http://twozerowest.com/snowdog%20gallery/admin.php'
, 1);
}
Anyone have ANY idea what's going on?
John Corry
email: jcorry@xxxxxxxxx