-1

I have a facebook iframe application not a fan page.
When i use this code it prints well

 $signed_request = $facebook->getSignedRequest();
 print_r($signed_request);

it prints:

Array (   
[algorithm] => HMAC-SHA256   
[expires] => 1341475200   
[issued_at] => 1341470027     
[oauth_token] =>...  
[user] =>   
   Array (    
         [country] => tr   
         [locale] => en_US   
         [age] => Array ( [min] => 21 )  
         )   
         [user_id] => ...  
       )

But when i change the url in adress bar like https://apps.facebook.com/myappname/?app_data=helloand push enter it doesn't prints app_data=hello parameter in array. How can i print it?


My application is iframe app. look at this pic You can go to my app http://apps.facebook.com/gayriciddi/ and click links on homepage and see

$view = empty($_GET['view']) ? 'home' : $_GET['view'];
    echo '<br />'.$view; 
    $testid = $_REQUEST['testid'];
    echo '<br />'.$testid.'<br />';

codes are work or not

.

my index.php:

<?php
    include ('config.php');
    include ('db_fns.php');
    header('Content-type: text/html; charset=UTF-8'); 

    print_r($fbme); 

    $controller = 'page';

    $view = empty($_GET['view']) ? 'home' : $_GET['view'];
    echo '<br />'.$view; 
    $testid = $_REQUEST['testid'];
    echo '<br />'.$testid.'<br />';

    $signed_request = $facebook->getSignedRequest();
    print_r($signed_request);

    //includes home.php
    include(WEBSITE_ROOT.'/views/'.$controller.'.php');
?>

my home.php:

    <table width="601" border="0">
 <?php foreach($testler as $key => $test){?>
  <tr>
    <td width="53">&nbsp;</td>
    <td width="420"><a href="<?=FB_BASE_URL?>?view=acilis&testid=<?=$test['id']?>" target="_top"><?php echo $test['ad'];?></a></td>
    <td width="50">&nbsp;</td>
    <td width="50">&nbsp;</td>
  </tr>
 <?php } ?>
</table>
Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
mcan
  • 1,914
  • 3
  • 32
  • 53

1 Answers1

0

Just use $_GET['app_data'] as it's not part of the signed request like in a page tab

TommyBs
  • 9,354
  • 4
  • 34
  • 65
  • $_GET from urls does not work in iframe applications. http://stackoverflow.com/questions/5019115/passing-custom-parameters-to-facebook-fan-page-tab in first answer and it's comment says that you can get app_data in url with signed_request parameter – mcan Jul 05 '12 at 11:33
  • That's a fan page tab question and not a canvas app. You said your app was an iframe app (I presumed you mean canvas app as you specifically said not a page) Get does work in this instance as I've just tried it. Just do a var_dump($_GET); on your page and add a querystring in the format https://apps.facebook.com/YOUR_APP_ID/?test=7 – TommyBs Jul 05 '12 at 11:40
  • TommyBs Please look at answer below. – mcan Jul 05 '12 at 12:07
  • I think there is something else up here then. If you look here https://apps.facebook.com/441989825822846/?get=12342&test=456436 change the querystring values to whatever you want and it will print out all the $_GET variables – TommyBs Jul 05 '12 at 12:24
  • also in your example you are setting $controller t="page" loading the view "page.php" yet you show the code in home.php – TommyBs Jul 05 '12 at 12:26
  • i first include page.php after that i home.php are included into page.php If you log in and look at the app you will see there is no problem – mcan Jul 05 '12 at 13:21
  • Is it possible you have a .htaccess rule or something else in your bootstrap that is removing these $_GET request? – TommyBs Jul 05 '12 at 13:22
  • No there is not a problem. I thınk you have to admit that GET method can not used in iframe facebook applications and stop forcing this way. Look at the comment http://stackoverflow.com/questions/11331364/can-not-get-url-parameters-in-facebook-canvas-application – mcan Jul 05 '12 at 13:25
  • Did you even look at the link I sent you of an iframe application that proves that $_GET paramenters can be used this way? – TommyBs Jul 05 '12 at 13:30
  • Can you post your code belongs to your link? I run off the rails. – mcan Jul 05 '12 at 13:55
  • I've simply got in that file so any $_GET parameters are printed out. All I can think of is if you have a rewrite rule or something similar causing issues. Try changing your links as well from target="_top" to target="_parent" and see if that has any effect – TommyBs Jul 05 '12 at 13:57