Created
          August 16, 2012 09:20 
        
      - 
      
- 
        Save meeDamian/3368694 to your computer and use it in GitHub Desktop. 
    [ PHP | FB | hacks ] Checking if current user (in a tab!) is a fan of a page
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <? | |
| function parsePageSignedRequest() { | |
| if( isset($_REQUEST['signed_request']) ) { | |
| $encoded_sig = $payload = null; | |
| list( $encoded_sig, $payload ) = explode(".", $_REQUEST['signed_request'], 2 ); | |
| $sig = base64_decode( strtr( $encoded_sig, '-_', '+/') ); | |
| $data = json_decode( base64_decode( strtr( $payload, '-_', '+/'), true ) ); | |
| return $data; | |
| } else return null; | |
| } | |
| $page_id="TU WPISZ PAGE ID"; | |
| $is_fan = false; | |
| if( $sr = parsePageSignedRequest() ) { | |
| $pages_math = (bool)($sr->page->id==$page_id); | |
| if( $sr->page->liked and $pages_math ) $is_fan = true; | |
| } | |
| if( $is_fan ) { /* jest fanem */ } | |
| else { /* fanem nie jest */ } | |
| ?> | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment