Ask your WordPress questions! Pay money and get answers fast! (more info)

WP fb page tab - Pass app_data back to tab after auth redirect WordPress

  • SOLVED

Hello,

I need some help please with my facebook tab. Which is wordpress driven.

In my header.php I have created my app instance, see below...

<em>if you see any problems with this, I would be grateful for any tips</em>

[[LINK href="https://gist.github.com/ca811423f428ce31dcf1"]]https://gist.github.com/ca811423f428ce31dcf1[[/LINK]]



So my problem is, if the user is not already authenticated, I lose my app_data variable when the auth redirect takes place.

Can anyone help me pass the app_data through the authentication redirect.



I managed to come up with this below, which is very dirty.


if ( $obj['app_data'] ) {
$appdataVar = '&app_data='.$obj['app_data'];
}

// Authentication
$auth_url = "http://www.facebook.com/dialog/oauth?client_id=" . $app_id . "&redirect_uri=" . urlencode($canvas_page.$appdataVar);


It worked, but it leaves undefined variables if no app_data was there in the first place?


Best answer will get the prize. Thanks.

Josh

Answers (1)

2012-10-11

Arnav Joy answers:

i think you should try this

<?php

if ( $obj['app_data'] ) {

$appdataVar = '&app_data='.$obj['app_data'];

}

else if($_GET['appdataVar'])
$appdataVar = $_GET['appdataVar'];

// Authentication

$auth_url = "http://www.facebook.com/dialog/oauth?client_id=" . $app_id . "&redirect_uri=" . urlencode($canvas_page).'&appdataVar='.$appdataVar;
?>


Josh Cranwell comments:

Hello,

I still 3 got undefined variable notices.


Josh Cranwell comments:

I mean...

I still get 3 undefined variable notices in my debug.


Sent you link on skype.

Thanks