Overview: Facebook API and Getting Access Token(Part-1)

In this article, which is going to be the Part-1 of the four part series, I am going to give you the in-depth analysis and overview of Facebook Graph API using Facebook Graph API Explorer. In the article “For Developers: Facebook's Graph API”, I have talked about what an API is, and what nodes, edges, fields, and few operations are. If you haven’t read that article, I would highly recommend you to read that article first. If you have read that, it is the time to have a look at the Graph API in depth. So without further ado, let us get started!

The very first thing that you need to know is that Facebook provide various SDKs for its API. Like iOS, Android, JavaScript and PHP SDK. Here, in this series, I am going to use Facebook SDK for JavaScript. Now the question is how you can use that SDK. Let’s have a look.

Facebook SDK for JavaScript

According to the official documents of Facebook SDK for JavaScript, the Facebook SDK for JavaScript provides a detailed and comprehensive set of client-side functionality that:

  • Enables you to use the Like Button and other Social Plugins on your site.
  • Enables you to use Facebook Login to lower the barrier for people to sign up on your site.
  • Makes it easy to call into Facebook's Graph API.
  • Launch Dialogs that let people perform various actions like sharing stories.
  • Facilitates communication when you're building a game or an app tab on Facebook.

Note(according to the official document): The SDK, social plugins and dialogs work on both desktop and mobile web browsers.

Testing Facebook API using Facebook Explorer

Before making the full-fledged JavaScript Authentication Application for Facebook API using Facebook SDK for JavaScript, we need to check and test the functionality of Facebook API. In the part-2, I shall talk about the Facebook Permission in detail, but for now let us just look at how you can test Facebook’s API.

Go to the following link:

https://developers.facebook.com/tools/explorer

And Log-in to your Facebook Account (as shown below):

Once you log into Facebook, you will see the following page:

As you can see I have labeled few of the fields with numbers 1, 2, and 3. Let’s discuss them one-by-one:

  1. It’s is the access Token for using the Facebook Graph API. I shall show you in future parts how you can use this token to make your own JavaScript Application for Graph API, but for now remember that this is required in order to use the API.
  2. Here you can see the query language. As you see the “me” has two fields “id, name.” You can use as many fields that Facebook API provides, but you will have to give user the permission to use this feature. In the Part-2 I shall talk about what permissions are and their list.
  3. As you can see I am using the Graph API Explorer for Facebook. Using this drop-down you can select your own Application to check the functionalities of your queries, but that’s not in the scope of this article.

Alright if you hit the “submit” button in (2), you would see:

The id and the name of your profile via which you have logged in, would be displayed upon hitting the submit button. I have blurred out my fields for privacy issues, but you would get yours if you execute the API.

Summary

In this article, I have introduced the Facebook Graph API Explorer, and I have also mentioned how you can run queries using this explorer. I have also given you the idea about the Facebook API SDKs, and which SDK I am going to use in my future parts. In the next part, I am going to talk about permissions in the Facebook API. That’s it for this article.

AUTHOR

READ NEXT

Boostlog is an online community for developers
who want to share ideas and grow each other.

Delete an article

Deleted articles are gone forever. Are you sure?