Facebook Login Api Tutorial Php
Posted By admin On 15/09/18OAuth is simply an open authentication that is used for providing access to the server data after authorizing a user via third party services. In this tutorial, we are going to explain how you can implement Facebook login via open authentication to connect with your website using CodeIgniter. You can achieve this login mechanism using Facebook PHP SDK. To start with, first the Facebook PHP SDK and save it in your CodeIgniter’s libraries folder. Before running script, generate your Facebook app id and Facebook app secret key, for this follow up the below given steps: You can also refer our live demo or download the Script file. Extract the downloaded files and run it on your Local server.
Steps for Getting Facebook App ID and Facebook App secret key: If you are looking for built in ready script, then you can try this. In Facebook open authentication, App Id and the App secret key are required for authenticating a valid Facebook account.
Facebook will also update the javascript sdk soon, so later you can use the login/logout system of javascript api with php sdk. But for now you should use fully php base authentication.
For getting this you have to do the following steps: Step 1: Go to and sign in by an existing Facebook username or password. Step 2: After login click on to Apps tab. Step 3: When you will click on to Apps button o ne drop down list will appear that will contain your previous added Apps. Now click on Add a New App. Step 4: After clicking on it one popup window will appear here you have to select a platform for which type of app you are creating, platform may be ios, android, any Facebook app or for any website, here we are creating apps for website.
Step 5: Here you have to write your application name based upon your choice and click on C reate New Facebook App Id. Step 6: In this window, choose a category and then click on Create App ID button.
Here, you will have two steps, in first steps you can create a test version of another app and in second step you have to choose a category for which type of apps you are creating. Step 7: For going to dashboard, click on Skip Quick start. Step 8: In Dashboard you will see your App ID and App Secret.Where App ID is visible and App Secret key is hidden, to see this click on show button, n ow that App ID and App Secret Key you have to add into your application code as shown below. // Load facebook library and pass associative array which contains appId and secret key $this->load->library('facebook', array('appId' =>', 'secret' =>')); This App ID and App Secret is only accessible by your own Facebook account, by default it is available for private, but for making public, click on settings link and follow step 9 & 10. Step 9: In setting,write your app domain name, your email id and then click on + Add Platform >Website to add Site URL. This will be used by the FB server on authentication to hand back control to your application. Step 10: Now go to Status & Review, set YES for your app features available to public.
As now since you have generated your app Id and app secret key, now you are ready to integrate and connect to your Facebook login account. CodeIgniter Facebook OAuth login Flow: • On accessing a website page the Facebook login button is shown.
The user will click the FB button to login into the codeIgniter application. • After clicking on that button a Facebook URL will be invoked that will contain App Id and App Secret Key. Relativistic Quantum Fields Bjorken Pdf Printer here. • Now Facebook will validate the application ID and then will redirect to its login page. • User will enter the FB login credentials and submit the form. Epson Stylus Cx5700f Driver Windows 8. Installer Canon Pixma Ip1000 Ubuntu Desktop. • In Facebook when validation will be success it will respond back with access_token that will contain the user’s detail. • Redirect URL page will forward to a page showing user data in the client browser.
We have created a CodeIgniter login example in that we have explain how you can connect your Facebook account via OAuth. You can create similar files as mentioned below and can copy the code. Cara Membuat Form Upload File Dengan Php Editor. If you like you can even download the files.
Below is our complete code with short explanation: Controllers: oauth_login.php Copy the below code in your controller. When you load Facebook library in your controller’s constructor writes your Facebook App Id and Facebook Secret Key. CodeIgniter: Login Facebook via Oauth 2.0 CodeIgniter: Login Facebook via Oauth 2.0 ';?>Views: profile.php Copy the below code in your view and save as profile.php. As anyone will login with the facebook he/she will see this page that will contain logged in user details.