javascript - How to check if a user likes my Facebook Page or URL using Facebook's API -


i think i'm going crazy. can't work.
want check if user has liked page javascript in iframe app.

fb.api({     method:     "pages.isfan",     page_id:        my_page_id, },  function(response) {         console.log(response);         if(response){             alert('you likey');         } else {             alert('you not likey :(');         }     } ); 

this returns: false
i'm fan of page shouldn't return true?!

i tore hair out on 1 too. code works if user has granted extended permission not ideal.

here's approach.

in nutshell, if turn on oauth 2.0 canvas advanced option, facebook send $_request['signed_request'] along every page requested within tab app. if parse signed_request can info user including if they've liked page or not.

function parsepagesignedrequest() {     if (isset($_request['signed_request'])) {       $encoded_sig = null;       $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;     }     return false;   }   if($signed_request = parsepagesignedrequest()) {     if($signed_request->page->liked) {       echo "this content fans only!";     } else {       echo "please click on button view tab!";     }   } 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -