views:

58

answers:

1

Hi

I have fabrook connect code in PHP like

$facebook = new Facebook(array( 'appId'  => FACEBOOK_APP_ID, 'secret' => FACEBOOK_SECRET, 'cookie' => true));
 $session = $facebook->getSession();

 $loginUrl = $facebook->getLoginUrl(
            array(
            'canvas'    => 1,
            'fbconnect' => 0,
            'req_perms' => 'email,read_stream,publish_stream,offline_access',
   'next' => 'http://apps.facebook.com/appname/')
 );

if (!$session) {
        echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>";
        exit;
    }

when user access too my application it redirect to facebook permission page. that user must click Allow to accept permission request.

when user Allow, my application return sime confuse URL such as

http://apps.facebook.com/appname/?perms=email%2Cread_stream%2Cpublish_stream%2Coffline_access&amp;selected_profiles=1756044141&amp;installed=1&amp;session={%22session_key%22%d221b6f2-1756044141%22%2C%22uid%22%3A%221756044141%22%2C%22expires%22%3A0%2C%22secret%22%5ffd193f40cc1c3acd%22%2C%22base_domain%22%3A%22muslimsquare.com%22%2C%22access_token%22%3A%22148835711801079|bdf70ed30-1756044141|wvq6bAErEPdDxMZ.%22%2C%22sig%22%3A%22478a31ffc9dcc55daa19aa0d72}

instead of

http://apps.facebook.com/appname/

how can i fix it to facebook return clean url (http://apps.facebook.com/appname/)

thankyou

A: 

That is because facebook adds session, application id and more information to the url by default. You can however, decode the url like this:

urldecode($url);
Sarfraz
@Sarfraz where i pass 'urldecode($url);' and how i get $url;
Giffary
@Giffary: You can get the current url with `$_SERVER['REQUEST_URI']`
Sarfraz
@@Sarfraz when i call urldecode($url); ? give me an idea please.
Giffary
You simply do this: `$url = urldecode($_SERVER['REQUEST_URI']); echo $url;`
Sarfraz