Tuesday, February 22, 2011

Creating facebook test user account for testing your facebook application

If you are developing some Facebook application then you will need to test it with different user accounts. You will even need network of user account meaning accounts with friends. You would not like to do the testing with your real Facebook account because while testing you might be posting lot of junk data to your wall and this will get published to your friends news feed. You even might require adding new friend and removing friends for the testing purpose.
One option is to create fake accounts. But this is not clean way of doing. You will have to create so many fake email account and you will have to fill lot of fake user info. And another thing is that Facebook deletes fake account once they find it as fake.
There is other clean way of doing. Facebook provide API to create test accounts. These accounts will not be deleted by Facebook. Unfortunately Facebook currently does not provide any GUI to create test account. You will have to use Facebook API to achieve this. 
Here are the things that will be required to achieve this:-
1) A web browser (preferably firefox, I have not tested it on other browsers)
2) wget command line utility. This is freely available and most of the Linux distro has this by default. ( other tools like curl can be used but I am describing here with the help of wget). The reason we use wget is that we need HTTP post method.

Step 1: Get the application access token.
Type this URL in web browser.

Replace XXXXX appropriately with your app ID and app secret.

This will give you access token. In the browser you see content like
Please note down this access token.

Step 2: Create test accounts.
We will need wget command line utility for this. Run this command line utility to create a test user
wget --post-data "installed=true&permissions=read_stream&access_token=TOKEN" https://graph.facebook.com/APP_ID/accounts/test-users
Replace TOKEN with what you got in the step 1 as access token and replace APP_ID with your Facebook application id.
Run this command as many times as many users you want to create.

Step 3: Get the login URL for each users:
Type this URL in you browser
Replace TOKEN with what you got as access_token in step 1 and replace APP_ID with your Facebook application ID.

This will give you Info for each test account created. The info also contains login URL. Copy and paste the URL in browser to login into the test user account.

Few more things:
- The login URL is valid for one session only. You will have to repeat the step 3 to get new login URL.
- Access token is gets expired after some time. repeat the step 1 to get fresh access token.
-  Refer the facebook documentation here for more detail

Monday, February 7, 2011

MySql reseting root password

I was experimenting MySql yesterday and set some password for the root account. But today I forgot. Doing little bit of search on the net, I came across a simple way to reset the password. For this the root access of the OS is needed. Here are the steps:
- Log in as root on the SqlServer box
- stop the MySql server. command: /etc/init.d/mysqld stop
- start mySql in safe mode. command: mysqld_safe --skip-grant-tables
- The previous command will not free the terminal. So from other terminal (command prompt) do these-
mysql --user=root mysql
update user set Password=PASSWORD('new-password') where user='root';
flush privileges;

- Kill the mySql daemon. Command: killall mysqld

- start the mysql daemon. Command: /etc/init.d/mysqld start