Search code examples
phpfacebookfacebook-iframe

Dynamic url in facebook app tab


I am newbie to facebook app and I am trying to create a first app of my php application as an iframe, I have created the app using

http://developer.facebook.com.

but in page tab url, I need some dynamic url like: I want to set url like :

http://mydomain.com/index.php?r=site/index&user_id=some_dynamic_value

How can I set this dynamic url for a tab url, can any one suggest me please


Solution

  • if you want to display different content on page tab depending on pages that using this apps.Here is my code of a simple app...

        <?php
        include_once 'facebook.php';
        include_once 'class/database.class.php';
        $db = new Database();
        $app_id = "$your_app_id";
        $app_secret = "$your_app_secret_key";
        $facebook = new Facebook(array(
        'appId' => $app_id,
        'secret' => $app_secret,
        'cookie' => true
        ));
        ?>
        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
          <!-- Header content -->
        </head>
        <body>
        <!-- Your body Content Here -->   
        <div>
        <div>
        <?php
        $signed_request = $facebook->getSignedRequest();
    
        $page_id = $signed_request["page"]["id"];
        $app_id = $signed_request["page"]["id"];
        $page_admin = $signed_request["page"]["admin"];
        $like_status = $signed_request["page"]["liked"];
        $country = $signed_request["user"]["country"];
        $locale = $signed_request["user"]["locale"];
    
        if($page_id){
            $sql="select * from coupon where page_id=" . $page_id . "";
            $result=$db->fetch_all_array($sql);
            $heading=$result[0]['heading'];
            $desc=$result[0]['desc'];
            $img=$result[0]['img']; 
        ?>
        <h1><?php echo $heading?></h1>
        <img src="<?php echo $img; ?>">
        <p><?php echo $desc; 
        }
        ?></p>
        </div>
        </div> 
        </body>
        </html>