1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Coding Help!

Discussion in 'PHP & Perl' started by pasenseoso, May 31, 2013.

  1. pasenseoso

    pasenseoso Power Member

    Joined:
    Aug 19, 2011
    Messages:
    754
    Likes Received:
    136
    Occupation:
    hachetman
    Location:
    - - P I L I P I N A S - -
    Home Page:
    Hi fellow BH,

    I am scrambling to get this code working but I miserable failed. It should suppose to redirect to either 2 pages. Pages for the likers and non likers. However, even if a user has liked a particular page, still there is no redirection or whatsoever. Can anyone help me fix this code? Its actually an FB fangate.

    Code:
    <?php
      $app_secret="xxxxxxxxxxxxx";
      $data = parse_signed_request($_REQUEST['signed_request'], $app_secret);
      $page_data=$data['page'];
    
    
      function parse_signed_request($signed_request, $secret) {
        list($encoded_sig, $payload) = explode('.', $signed_request, 2);
    
    
        // decode the data
        $sig = base64_url_decode($encoded_sig);
        $data = json_decode(base64_url_decode($payload), true);
    
    
        if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') {
          error_log('Unknown algorithm. Expected HMAC-SHA256');
          return null;
        }
        // check sig
        $expected_sig = hash_hmac('sha256', $payload, $secret, $raw = true);
        if ($sig !== $expected_sig) {
          error_log('Bad Signed JSON signature!');
          return null;
        }
    
    
        return $data;
      }
      function base64_url_decode($input) {
        return base64_decode(strtr($input, '-_', '+/'));
      }
    
    
      if($page_data['liked'] == "1"){
    
    
        // Fan Content
    
    
      }else{
    
    
        // No-Fan Content
    
    
      }
    ?>
    
     
  2. Kalashnikov

    Kalashnikov Junior Member

    Joined:
    Feb 18, 2011
    Messages:
    148
    Likes Received:
    59
    Location:
    Northern Ireland
    echo the variable to see what it outputs.
     
  3. pasenseoso

    pasenseoso Power Member

    Joined:
    Aug 19, 2011
    Messages:
    754
    Likes Received:
    136
    Occupation:
    hachetman
    Location:
    - - P I L I P I N A S - -
    Home Page:
    I have tried it, yet still it does not redirect (I actually used redirection instead of showing content). Maybe there is a new script for fb fan gating (for websites and not page tab)?
     
  4. shubhamm

    shubhamm Junior Member

    Joined:
    Jan 25, 2010
    Messages:
    107
    Likes Received:
    25
    Occupation:
    Developer
    Location:
    BHW
    there are lots of fb scripts online which can help you in redirect the non fan user and fan user
    & are you sure you are putting right APP_SEcret
     
  5. pasenseoso

    pasenseoso Power Member

    Joined:
    Aug 19, 2011
    Messages:
    754
    Likes Received:
    136
    Occupation:
    hachetman
    Location:
    - - P I L I P I N A S - -
    Home Page:
    Yup I did put the right app secret. Yes it does work to filter non page likers.. But even if you hit the like button and refresh the page, nothing happens...