May 30, 2008
When developing facebook applications, we might need an infinite session that will enable us to update the app users’ profile periodically. For instance, a “Quote Of TheDay” application needs to update its users’ profile everyday with a new quote.
Here are the steps to generate an infinite session that does not expire. Note: these steps only need to be done by the developer once; no action is needed from the app users.
- Login to your own facebook account.
- Browse to: http://www.facebook.com/code_gen.php?v=1.0&api_key=YOUR_API_KEY (replace YOUR_API_KEY with your app’s API key) Click through the simple instructions on the page. After that, you’ll be provided with a one-time code like 5P4I8D .
- Invoke facebook API auth.getSession using the one-time code. The returned result will be the infinite session key.
Source of info: http://wiki.developers.facebook.com/index.php/Authentication_guide
No Comments » |
facebook, web 2.0 |
Permalink
Posted by singchyun
May 30, 2008
When developing Facebook application for Pages, it is mandatory to “stay in Page context” in order for <fb:page-admin-edit-header/> to be rendered. Thanks to Thought Labs Blog, for documenting the way to do so:
you MUST add the ‘fb_page_id=[pageID]‘ URL param to the POST URL.
No Comments » |
facebook, web 2.0 |
Permalink
Posted by singchyun
May 30, 2008
It’s frustrating when PHP compilation errors are not shown during development. To make such compilation errors visible on the web pages, add this line in .htaccess:
php_value display_errors 1
Alternatively, if access to .htaccess is not allowed, this PHP code achieves the same result too:
ini_set(’display_errors’,1);
No Comments » |
php |
Permalink
Posted by singchyun
December 13, 2007
To log each and every query executed by MySQL, simply specify “-l” when starting mysqld_safe. For instance:
/usr/bin/mysqld_safe -l ...
All queries will then be logged to <hostname>.log in the data directory (typically /var/lib/mysql).
No Comments » |
mysql |
Permalink
Posted by singchyun
August 3, 2007
A quick start guide to Grails
There was a period of time when Java developers can only envy the RoR developers for completing the day’s work by lunch time. Not anymore, for we have Grails to the rescue!
After exploring Grails for an hour, I’m really impressed by its fuss-free scaffolding. (In an hour, I had enough time to touch on the basics and to write this post. Ha ha
) Don’t be convinced by me, you’ve gotta try it for yourself to believe it.
Ok, first of all, we will need to install Grails, which is nothing more than just:
- Download and unzip Grails.
- Define a GRAILS_HOME environment variable to point to the unzipped Grails directory.
- Add $GRAILS_HOME/bin to your $PATH.
Installation is complete!
Now let’s begin writing our very first “real-world” application. For starters, our application will help to manage seminars and registrations. Execute these steps on your shell:
- grails create-app myapp
- cd myapp
- grails create-domain-class Seminar
- grails create-domain-class Registration
- Edit myapp/grails-app/domain/Seminar.groovy:
- class Seminar {
String title
Date startDateTime
String city
Float cost
Boolean mealsProvided
static hasMany = [registrations:Registration]
}
- Edit myapp/grails-app/domain/Registration.groovy:
- class Registration {
String name
Date dateOfBirth
String gender
Seminar seminar
}
- grails generate-all Seminar
- grails generate-all Registration
- grails run-app
That’s all the code you need to write to set up the scaffolding! Let’s enjoy the fruits of our labour by browsing to http://localhost:8080/myapp. You’ll notice this scaffolding automatically includes:
- CRUD functionalities for both our Seminar and Registration domain classes.
- In the Registration data entry page, the Seminar field is rendered as a dropdown list of all Seminar objects.
- In the Seminar data entry page, the MealsProvided field is rendered as a checkbox.
Here are some screen shots of the scaffolding:


Oh, did I mention the one hour also includes a trip to the kitchen to reward myself with a cuppa coffee?
For further reading, I recommend this wonderful and FREE e-book: Getting Started with Grails by Jason Rudolph
3 Comments |
java |
Permalink
Posted by singchyun