To do write code to sign in with Facebook, you need to have APP ID and APP SECRET.
To use this app you need to download the SDK Facebook: http://developers.facebook.com/docs/reference/php/download/
Refer to the API documentation of Facebook:
- GRAPH API: http://developers.facebook.com/docs/reference/api/
- Permission Detail: http://developers.facebook.com/docs/authentication/permissions/
Put the following code to PHP files to be processed log
- <? Php
- require 'facebook / facebook.php';
- $ FbPermissions = 'email, publish_stream, user_photos';
- $ Facebook = new Facebook (array (
- 'AppID' => '510685512391982',
- 'Secret' => '76ef9a5f323613670fe1f1d0f1f0dffd'
- 'FileUpload' => true,
- 'Cookie' => true
- ));
- $ User = $ facebook-> getUser ();
- if ($ user)
- {
- tRY
- {
- $ User_profile = $ facebook-> api ( '/ me');
- if (! empty ($ user_profile))
- {
- $ User_id = $ user_profile [ 'id'];
- // The processing your login here offline
- }
- }
- catch (FacebookApiException $ e)
- {
- $ User = null;
- }
- }
- else
- {
- $ LoginUrl = $ facebook-> getLoginUrl (array ( 'scope' => $ fbPermissions));
- }
- ?>
- <Div class = "sign-in-bound">
- <H4 class = "subtitle"> </ h4>
- <P> <b> Click the button below to log in with your Facebook account. Your account will be created automatically after the first login without registration. </ B> </ p>
- <br clear="all">
- <Div align = "center"> <a href="<?php echo $loginUrl;?> "> <img src =" skins / news / images / loginfacebook.png "> </a> </ div>
- <br clear="all">
- <P>
- <B> You can also log in with an account registered in Goccuoi.net. If you do not have
- account, <a href="dang-ky.html" </a> style="text-decoration:underline"> register here. </ b> </ p>
- <Div class = "log-input" style = "margin-top: 18px;">
- <Form name = "SignInForm" method = "post">
- <Div>
- <Label for = "user_id"> Name </ label> <span class = "required"> * </ span> </ div>
- <Input name = "user_id" type = "text" id = "user_id" class = "input">
- <Div> <label for = "password"> Password </ label> <span class = "required"> * </ span> </ div>
- <Input name = "password" type = "password" id = "password" class = "input">
- <Div>
- <Input name = "save_password" type = "checkbox" id = "save_password">
- <Label for = "save_password"> Automatically login next time </ label>
- </ Div>
- <Div style = "margin-left: -4px; margin-top: -10px;">
- <Input class = "search-button" type = "submit" value = "Login">
- Forgot your password <a href="quen-mat-khau.html"> </a>
- </ Div>
- </ Form>
- </ Div>
- </ Div>
If you have any questions, please comment down below for inquiries
Thank you for your share, its very important for me..
ReplyDelete