php - Facebook app permissions error -
i have code facebook web app:
<?php if (!$user_profile) { ?> <div class="fb-login-button" data-perms="email,user_birthday,publish_stream">login facebook</div> <?php } else { ?> user profile <pre> <?php //print htmlspecialchars(print_r($user_profile, true)) ?> </pre> <?php echo $user_profile['name']; ?> <?php $data = array("message" => "hello woghfd!"); $status = $facebook->api("/me/feed", "post", $data); //echo $user; ?> <?php }
i have code, simple thing post users wall. know need permission of publish_stream, ive included in button (at top) when user visits site error:
fatal error: uncaught oauthexception: (#200) user hasn't authorized application perform action
now when user logs out of facebook via facebook, , logs in using login button, works ok, how can set dioesnt show error when first visiting site??? confusing!
thanks :)
your if statement doesn't check if user has authenticated app:
if (!$user_profile)
to check if user has authenticated, this:
try { $fb_userid = $facebook->getuser(); // user authenticated continue normally... } catch (facebookapiexception $e) { // user not authenticated, else... }
Comments
Post a Comment