Managing Test Users in Facebook

Recently Facebook implemented a new and more secure way of creating test users for your applications using the new Graph API. This new resource creates test users per application, allowing the developers of these apps to login as these users and test out their app’s functionality without using their own accounts and throwing test information into their live activity feed, this makes it very easy and clean to test new applications.

Its possible to create up to 100 test users per app, creation allows you to choose whether the user already should have the application installed and which permissions you want them to have, using API calls like:

POST /app_id/accounts/test-users?installed=true&permissions=read_stream

You can also remove users, list all of your app’s test users and even create friend connections between them using the API. This really is a great resource, but using an API to get this information all the time is cumbersome and might take time away from your time to develop the application itself.

This is where the Test User Manager comes in.

Having ran into this exact issue when developing for Facebook, I wished i could have a “phpMyAdmin”-like application to handle these requests for me and just give me a simple interface to work with. That’s when the idea was born an i decided to use the idea and opportunity to simplify my life and also learn/research a few other libraries and such.

I decided to create a very simple app, without a large MVC framework, just a bunch of actions. I also took the opportunity to use a simple template engine to see how it behaves, so i chose Twig for this. Since i did not have the comfort of large MVC framework to handle my requests, i also decided to look at funkatron’s Inspekt library to handle input security. Since i did not want to go through some troubles I also imported a limited set of tools from Zend Framework to handle autoloading and smaller tasks. Also having not worked with front-end too much in a while I took hold of jQuery and a few plugins to see what they could do.

All in all i had a very simple but effective app. Right now (version 0.9) it does the basics, add, lists, deletes and creates relationships between Test Users. But it handles exactly the most boring and annoying tasks. Let me show you a bit:

Listing/Managing Users

Screenshot of App

Test User Manager for Facebook: List/Manage Users

The user list will show you all of your test users, their IDs, name and permissions. With the command icons you can see the access_token, login on Facebook as the user, delete him or add new friends. Since this is a API heavy process to get all information loading is done in parallel using ajax.

Creating a User

Screenshot of adding user

Test User Manager for Facebook: Add user

The for to add new users is straight forward, you can add permissions and decide if the app will be installed or not for the user.

Viewing and Creating relationships

Screenshot od add/view friends

Test User Manager for Facebook: Add/View Friends

Clicking on the “add friend” icon you can view a list of existing relationships and choose a new user to associate with this user.

All the source code for this application is on GitHub, feel free to open feature requests and bug reports and of course pull requests at will. I hope this app can help you as a Facebook developer and make everyday life easier.

Download version 0.9 here

5 thoughts on “Managing Test Users in Facebook

  1. I met following warnings, and it cannot remove user, display tester detail information.
    Thanks a lot.

    PHP Warning: array_filter() expects parameter 1 to be array, null given in C:Program FilesEasyPHP- on line 26

    PHP Warning: array_keys() expects parameter 1 to be array, null given in C:Program FilesEasyPHP- on line 26

    PHP Warning: implode() [function.implode]: Invalid arguments passed in C:Program FilesEasyPHP- on line 26

    • Terence,I'm opening an issue on GitHub to look at this.If you can provide anymore details it would be great also.

  2. The application is a great idea. One problem thought, the Ajax component that pulls the user detail seems to fail on any browser I try (IE, Chrome, Safari). I've debugged it a bit. The Ajax calls suceeds, but the loading layer is never hidden and the data is never loaded (even thought those lines of codes do seem to execute). There are no errors in the console.

    • Alex,I would need to access your app to figure this out. I was unable to reproduce this locally.

      • It's complicated since we are running the app on our local network. I'll look into setting up a separate version.

        Btw, what browser do you use? Anything I should be on the lookout for?

  3. I would need permission to check on that. Let me back to you on that. Is there a more private way to communicate?

  4. I installed apache and php5 and when I tried to lunch the program it appear this:

    Fatal error: Uncaught exception 'Exception' with message 'Facebook needs the CURL PHP extension

    And i don know how to solve. Can you help me?'
    Thanks !!

  5. Thanks Rafael. Now I can see the main page of Facebook Test User but i have an other problem:

    connect() timed out!.

    I edit the config.ini.php

    define('FACEBOOK_APP_ID', '19639440370####');

    What I'm doing wrong ?.
    Thaks a lot !

    • Could you please send me more information about the error? the complete message, line, file etc…

      Could be that the API is down or something?

      • The complete message is: connect() timed out!

        line 44: <p class="error_msg">connect() timed out!

        File: layout.html.

  6. thanks this is exactly what I was looking for as Im building an iPhone app using the facebook SDK and am not very familiar with scripting/php on the web.

    Sorry seriously newbie web-dev question but do I just need to copy this across to a directory on a web server in order to run (I did this but am getting a '403 forbidden' message on my Apache server when I hit the folder URL) or is there some type of installation process that Im missing? Thanks again – once I get this working it will be a real time saver (dont know why FB havent built this to be honest).

    • @DaveThe 403 might be an indication of folder permissions and the apache user. But other then that you just need to enable the mod_rewrite module, and set AllowOveride to All or similar, and of course, have PHP available.All of this is pretty well documented around the web, a google query on each should get you up to speed.

  7. I am getting the following message: "SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed" What would this be caused from?

    • Turns out I was able to figure this out… Within the facebook.php file I needed to add the following lines to the $CURL_OPTS array:


      • I had the same error and after a google search came up with this fix (instead of disabling the verification):

        1. download mozila.pam file. See this page for more info:
        2. copy file to C:WINDOWSsystem32
        3. Add this to $CURL_OPTS array in facebook.php:
        CURLOPT_CAINFO => 'C:WINDOWSsystem32mozilla.pem'

  8. Hey Rafael,

    Thanks for posting this stuff to Github, I'm going to download and give it a try.

    Here's a question related to test users… Do you have any idea of a way, when using a test user on your application, to have the test user identify itself as a tester?

    I'm trying to create accurate statistics for an application, and the large number of test users I use is undoubtedly throwing things off.

    Thanks for anyone who has an idea!


  9. Hi..
    I got the error 500 on a shared host..
    Internal Server Error
    The server encountered an internal error or misconfiguration and was unable to complete your request.

    can you please help me how to solve it.?


    • Bruno,Please look at you Apache error log. I would suspect you might not have mod_rewrite enabled or your AllowOverride settings are set to None.

  10. hi, this is very helpful app. i have one test users hanging, cannot delete but can see user's fb account. how to force delete? thanks a lot.

  11. This is a great tool!

    One question: I presume that one needs to browse to the "/public" folder? If I do so, I get an error saying

    Warning: Unexpected character in input: '' (ASCII=92) state=1 in public/index.php on line 5
    Parse error: syntax error, unexpected T_STRING in public/index.php on line 5

    Dunno what I'm doing wrong here… :-P Can you help?

    • Do you have PHP 5.3? that looks like the error you usually get with namespaces in PHP 5.2 that does not support them.

  12. If you have problems with the app, make sure that you have:

    – support for .htaccess files
    – apache mod_rewrite is enabled
    – running on PHP5
    – installed PHP5 cURL extension
    – installed a cURL certificate that enables HTTPS transfer via cURL

    If above conditions are true, the app works like a charm :)

    Thanks for the tool, I was just about to write one myself and now I don't have to. Yay!

    • thanks for the requirements, will update the README file with more details.Glad it helps.

Comments are closed.