Facebook PHP SDK Tutorial – Get Email and Profile Pic

Hello friends, on the last Facebook PHP SDK Tutorial we have created a simple login app. In this Facebook PHP SDK Tutorial we will do some more interesting things. We will get the email, username and …

facebook php sdk tutorial

Hello friends, on the last Facebook PHP SDK Tutorial we have created a simple login app. In this Facebook PHP SDK Tutorial we will do some more interesting things. We will get the email, username and the profile pic from the facebook account. So lets get into it.

Setting UP Things for Facebook PHP SDK Tutorial

  • We have already done this but if you haven’t read the last tutorial you should check it from the link below.

Facebook PHP SDK Tutorial – Part 1

  • So lets move ahead.

Designing Your HTML with CSS

  • In this part of Facebook PHP SDK Tutorial we will try to make our layout looks good, So we will do some CSS as well.
  • Here is my CSS Code.

Using Session to Check a User is Logged in Or Not

  • If the user is logged in successful we will set a session, so that we don’t need to login everytime.

  • Now at the top we will check, if the session is already set. If the session is already set we will initialize our session so we do not need to login again.

  • Now we will create a logout link.

  • On logout we will unset the session.

  • We will be accessing the birthday and email of the user this time, so we need to set permission.
  • On getLoginUrl we will pass an array as argument.

  • Finally we will get the user information

  • We have all the details now.
  • So we only need to display the details in our page.

  • We will also create a logout button with the URL we already defined.

  • Thats it, you can see the final code for our index.php below

  • Try running your project.
  • Bravo! Its working, so thats it for this Facebook PHP SDK Tutorial friends. Comment if having any confusions or troubles. Thank You 🙂
  • You can also download the source code of this Facebook PHP SDK Tutorial from the link given below.

[easy_media_download url=”https://dl.dropboxusercontent.com/s/kmbcm7zpfzqwe2f/Facebook-PHP-SDK-Tutorial.zip?dl=0″ text=”Download Source”]

Hi, my name is Belal Khan and I am a Google Developers Expert (GDE) for Android. The passion of teaching made me create this blog. If you are an Android Developer, or you are learning about Android Development, then I can help you a lot with Simplified Coding.

Expand Your Knowledge: Next Tutorial Picks

0 0 votes
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x