Saturday, March 17, 2012

Facebook: An error occurred please try again

Working on Facebook APIs is quite an interesting experience but at times it could become pain in neck when you find no proper error message from the platform.

Recently I started working on an Fb app. I had made a testing account where I put the code so that client keeps seeing the progress. Last night I pushed the changes from local to remote site and made all necessary changes; Client Key, Secret  Key, putting remote redirect_uri but I kept getting error:

An error occurred please try again
I was really not being able to figure out what's going wrong despite of putting all things correct in my PHP script, the issue was that the Redirect URI or Site. See the image Below:

No matter what url you use for redirection in your code, it MUST be the URL mentioned here.

It took me a while to figure out but finally I made it. Hope it would be helpful for some :D

Saturday, March 10, 2012

Optional Parameter in Javascript

Javascript does not officially allows you to declare optional parameter but there is still a way you can handle them. Here we go!

function generateForm(id)

    var editable = false;

    if (arguments.length == 1 && typeof id!= "undefined")


        editable = true;




        alert("add form");




        alert("edit form");



As you can see, what all I did that I checked the length of given arguments and then also checked whether there is undefined type, there would be an undefined type if you provide no parameter. By simply checking this you can implement optional parameters