php - facebook login using oauth -


<?php require "facebook.php";  $facebook = new facebook(array(     'appid'  => '3288@@@@@@@@@@',     'secret' => 'ca2@@@@@@@@@@@@@@@@@@', ));  $user = $facebook->getuser();  if ($user) {   try {     $user_profile = $facebook->api('/me');   } catch (facebookapiexception $e) {     $user = null;   } } ?> <?php if ($user): ?>     <form action="#" method="get">       name:  <input type="text" name="name"             value="<?php echo $user_profile['name'] ?>"><br>         kid's name <input type="text" name="kid"><br>         dob <input type="text" name="kid" value="<?php echo $user_profile['birthday'] ?>"><br>         address <input type="text" name="kid" value="<?php echo $user_profile['email'] ?>"><br>          kid's gender          male<input type="radio" name="r" value="male">               female <input type="radio" name="r" value="male"> <br>           email:   <input type="text" name="name"             value="<?php echo $user_profile['email'] ?>"><br>         <input type="submit" value="continue &rarr;">     </form>     <a href="<?php echo $facebook->getlogouturl() ?>">         logout of facebook     </a> <?php else: ?>     <a href="<?php echo $facebook->getloginurl() ?>">         login facebook     </a> <?php endif ?> 

i have created app , have app id , secret key . need whenever new user click on login page , pre filled form pages when logged in , showing details , when user logged in , showing me nothing

it's showing information because created app , automatically given permission.

for others, need app ask permission first.

the first thing should this:

$params = array(   'scope' => 'read_stream,publish_stream',   'redirect_uri' => 'https://www.myapp.com/login_approved.php' ); $url = $facebook->getloginurl($params); echo '<a href="' . $url . '">give app access!</a>'; 

and create login_approved.php or whatever page want handle happens when approves app. notably should record user's access token. need provide user's access token app's access token @ information.


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -