Quantcast
Viewing all articles
Browse latest Browse all 10

New way to create test users in Facebook

Introduction

As mentioned in the Facebook developer docs, test users can only be created using a call to the Graph API.
As described in my previous Facebook article, a dedicated webpage was available at the time to create test users, however, that page has been brought offline. 

You can create a test user associated with a particular app using the Graph API with your app access token.

https://graph.facebook.com/APP_ID/accounts/test-users?
  installed=true
  &permissions=read_stream
  &method=post
  &access_token=APP_ACCESS_TOKEN
Image may be NSFW.
Clik here to view.

However, before we’ll be able call this API, we first need to retrieve an Access Token for our application.

Application Access Token

Before you get started, you might want to startup a text editor to copy paste some of these URLs and values (application ID, application secret, access token) as you’ll need to construct a lot of URLS that include these values.

In order to get an Access Token for our application, we need to know our Application Secret.

The first thing we’ll need is our Facebook Application ID. The Application ID is a unique identifier that you received while creating your application.
We’ can use the URL below to retrieve our Application Secret. Fill in your Application ID in the following URL to goto your Facebook App page and retrieve the Application Secret.

http://www.facebook.com/developers/editapp.php?app_id=YOUR_APP_ID

Image may be NSFW.
Clik here to view.

Now that we have the Application ID and the Application Secret, we can retrieve an access token for our application. In order to do that, we need to call the following URL with our Application ID and Application Secret.

https://graph.facebook.com/oauth/access_token?
	client_id=YOUR_APP_ID
	&client_secret=YOUR_APP_SECRET
	&grant_type=client_credentials

You’ll receive the following response:

access_token=109688035775165|hZe8qX8el6Qlp0xMyoAb5giYRls

Creating the test user

Now that we have our access token, we can do the task at hand, and use the Graph API to call our test-user.

https://graph.facebook.com/APP_ID/accounts/test-users?
  installed=true
  &permissions=read_stream
  &method=post
  &access_token=APP_ACCESS_TOKEN

With everything filled in, your request should look resemble something like this:

https://graph.facebook.com/109636235495125/accounts/test-users?installed=true&permissions=read_stream&method=post&access_token=109636235495125|qZe8yX8eL6zlp0xMGoAj5girRlS

If all went well, you should get a response similar to this:

{
   "id": "10000123432213",
   "access_token": "109636235495125|2.DFDGayE7X1s9ft_N7k94_E__.3600.1304802000.0-100002332671439|HhwACDVFeNhQ_UV0tQY0mUzkvLs",
   "login_url": "https://www.facebook.com/platform/test_account_login.php?user_id=10000123432213&n=R3feV4O7YrlIb0n",
   "email": "some_one\u0040tfbnw.net",
   "password": "3123123123133"
}

This basically means your test user has been created, and you can login to Facebook with this account. Use the email address (some_one@tfbnw.net) to login, and the password provided in the response.

You can change the password to a more convenient value for testing.

References


Viewing all articles
Browse latest Browse all 10

Trending Articles