Facebook offline_access is offline now

Okk, “moment de verite”, Facebook offline_access extended permission has been on 5th December 2012. Why? I don’t know but if I ask myself, I think its mainly because of security or abusive use.

So, what happens to those who are currently using Facebook offline_access extended permission?

<h2>How is it now?</h2>
Though there is no longer offline access, there is the capability to extend short lived session. Facebook automatically renews short lived session I think every 1 to 2 hours but if you want to use the access token for longer period, ensure that you renew it. So, yeah, for now, to confirm, long-lived session are for 60 days while short-lived one are for 1-2 hours.

for those who were not using the extended permission offline_access, you have no changes to make to your application. But application using offline_access will have to add some chunks of code for new users. If you were using offline_access extended permission, this will no longer be asked in the application login dialog box when the user uses your application. For new users, you’ll get a short-lived token which you will use to extend to get a long-lived one. Now, if you try to extend a token which already a long-lived one, you may get the same token or a token with a longer expiration time.

To get a long-lived session, just make a call on this URL with the required parameters replaced,

https://graph.facebook.com/oauth/access_token?

client_id=APP_ID&
client_secret=APP_SECRET&
grant_type=fb_exchange_token&
fb_exchange_token=EXISTING_ACCESS_TOKEN

So, it make sense for you to have a short-lived token before submitting the above request

Further information goes here:)
1. http://developers.facebook.com/roadmap/offline-access-removal/
2. http://developers.facebook.com/docs/howtos/login/extending-tokens/
3. http://stackoverflow.com/questions/10487049/facebook-long-lived-and-short-lived-access-tokens-and-their-expirancy-after-off

RESTful Web Services, return an Id or a URL?

In the RESTful world, there is a discussion about whether to return an id or a URL. Some RESTful Web Services returns identifiers while others complete URL for resources. But which one to use? Ok, suppose that our Web Service returns JSON encoded data and that a User can takes several books on loan.

Now, suppose a GET /user/1/books returns book ids on loan for user 1 as {41,56,67,12,89,23,56}.

So, the discussion is whether to return {41,56,67,12,89,23,56} or {"http://baseurl.com/book/41","http://baseurl.com/book/56",
"http://baseurl.com/book/67","http://baseurl.com/book/12",
"http://baseurl.com/book/89","http://baseurl.com/book/23",
"http://baseurl.com/book/56"}

After reading several articles and blogs, I’ve found that numerous developers prefer the second one because the baseurl can be changed without affecting the application. However, I completely disagree with this because even with the first one, the base url can be made dynamic. Also, with the second one, unnecessary data are sent back with is cumbersome.

But, I prefer a different solution. Suppose you have a REST interface running at http://example.com/v1, I find it better to expose the base URL itself. Say that a GET http://example.com/baseURL returns http://example.com/v1. Then, you can just get the base URL once that application first start up, and put it in a global variable so that it can be accessed everywhere throughout the application.

This is a solution which I though on the fly after reading several posts advising the use of complete URL. It may be wrong but one thing for sure, returning completing URL for a resource may good but not the best.

How we should probably program on the web in 2012 and after?

Web development in 2000 and 2012 is surely not the same. Today, when we develop on the web, we need to consider many aspects which we wouldn’t do 12 years back. Modern Web Development techniques and technologies have had lots of implications.  Some of the aspects which are considered to be very important are:

1. Don’t forget Mobiles

Modern Web Development-US Mobile Devices Penetration

Image obtained here

I was googling and it happened that I landed on a very interesting article containing lots of statistics. In it, you’ll notice one very interesting prediction which I believe to be true. Mobile has currently a great share in the Modern Web Development World. This will intensify….

By 2014, mobile internet gonna take over desktop internet.

By that, if you are developer, you’ll surely understand the implications. So for every website/web application you are developing, ensure you have it’s mobile alternative. The big boss Google/Facebook….. are doing this, so don’t diverge from the best practice.

But how to develop a mobile browser version for each desktop browser version? The next one answers it :)

2. Develop an API

Strive to build a web service for your web application. By doing so, sky is the limit. Because, you can easily build a mobile version of your application in either native/web view easily just making your web application inter-operating with the web service.. Again, the big boss Google/Facebook, so …..

Read this and notice how developers are making their web application using web services to reflect Modern Web Development practices.

2. Be fair to all browsers’ users

Browser Statistics

Statistics obtained here

You cannot tell everyone to use Google Chrome just because it’s the best.  Just ensure that your web app is as beautiful and functional on all browsers as it is on Google Chrome :-)

3. Use a framework

Sometimes, it’s a bit difficult to use a different framework because that changes the way we program. But it’s important. The fact is that framework (be it a server-side for PHP, Ruby,Java…., client-side for JavaScript such as jQuery or for CSS such as BluePrint), regroups set of best practices that it is difficult to apply when writing raw codes. e.g. When writing raw SQL in PHP, you might create holes for SQL injection or when using raw JavaScript, you might write codes that may not be compatible for all browsers. So, check out a good framework and use it.

Now, what’s a good framework?
a. One which is “non-authoritative” will make it. That is, it doesn’t forces any convention on you, if you use it’s great and if you don’t, it doesn’t bother.

If you check Fat Free, I’ve never use it, but reading it’s documentation tell me one thing, you just include the base.php file and use whatever features you like. You can use its ORM, MVC structure or also implement your own application level conventions.

b. Secondly, choose a framework that utilizes open source tools so that tomorrow, if you want to use these tools in isolation in a different environment, you already have the expertise. e.g. Symfony 2 clearly lists in its documentation that it uses external software as its building block such as Twig as templating engine or Doctrine as ORM.

5. Don’t forget Social Networks

Modern Web Development-Social Sharing

Obtained here

If you forget social network, you are implicitly telling 2 billion users to forget you. Modern Web Development advises you to integrate your site with social networks just to make people aware that you exist. Then, if your content is of value to them, they’ll come like swarm of bees.

Here are some convincing articles I found concerning social networks:

  1. http://www.jeffbullas.com/2011/09/02/20-stunning-social-media-statistics/
  2. http://blog.hubspot.com/blog/tabid/6307/bid/5965/The-Ultimate-List-300-Social-Media-Statistics.aspx

6. Be SEO Friendly & Google Friendly at the same time

 

Modern Web Development-Google Spiders

You are doing a website and you want to have traffic on it. So, first, learn how to create traffic. Learn the best practices for making your websites SEO friendly. If you are using CMSs, make sure you use the proper plugins to increase traffic and adhere to SEO practices. Also, ensure you’re site is Google Friendly because currently Google is leading, so lead with him. Ensure to properly spoon-feed Google Spiders so that they choose to build their “web” on your site. My blog is very new & “premature”, still my statistics says this:
Top Search Engine

RIA-Rich Internet Applications

We believe that RIA are modern Internet Application but I think RIA came into existence the moment JavaScipt took birth at Netscape. It’s really at that time that client-side web app started to become “rich”.

Why “Rich” ?
In typical websites, all interface are created on the server-side. The browser only renders the HTML. However, in RIA, server acts only as a model and supplies data. The interface and business logic is implemented in the client code. So, in typical websites, the client is a “thin client” in that it only renders HTML. However, in RIA, as mentioned above, the client is responsible to create the interface and also to implement a connection module to connect to the server.

Wikipedia definition for a RIA consist mainly the following parts:

  • has many of the characteristics of desktop application software
  • typically delivered by way of a site-specific browser, a browser plug-in, an independent sandbox, extensive use of JavaScript, or a virtual machine.”

However, I disagree with this clause “typically delivered by way of a site-specific browser, a browser plug-in”. Several frameworks make use of plugins to display Internet Applications.However, plugin is not a metric to determine whether a web application is an RIA or not. For me, RIAs only mimic desktop application software and try to inherit their traits. Personally, I see 2 main traits that RIAs try to mimic:

1. High Interactivity

In RIA, we don’t wait, they are very responsive and information is on demand(though it is not). In typical websites, users are more tolerant and they consider waiting as natural. However,RIA models desktop applications which tend to be very “fast”. Bandwidth can be a bottleneck leading to latency.Thus,latency need to be hidden/abstracted though it exists. I’ll try to answer the question “How to decrease latency?” below. Also, interaction is not only one way, from users to application but also from application to user. RIA interact with the user by making users to experience their richness through their fantastic designs and behaviors. The design is what I called the Data Presentation. The behaviors are the amazing effects that RIA exhibits such as fadeIn/fadeOut, transitions, drag and drop. In short, RIA need to be “young”, “gorgeous” and must “flirt” with the user in the smoothest way.

2.Data Presentation

On seeing RIAs, you’ll immediately notice that the widgets in the interface is different. Sometimes, you’ll see charts showing updated data on a real-time basis. There’ll be widgets are being updated by xmlHTTPResponses without even the user noticing it. The application structure of a RIA is somewhat different from a normal web application. Consider the following MVP pattern:

Application Structure

If we model an RIA using an MVP pattern then the client-side code is the View and the Presenter. The server only acts as a model for the RIA. All the codes for business logic and interface generation including a module to connect to server makes up the client. Initially all codes are obtained from the server. Thereafter, only data is obtained from the server through request made by the client communication module.

Now, I’m in a better position to answer the question, “How to decrease latency?”
1. Implement the MVP pattern described above to implement your RIA. By doing so, you’ll ensure that after the initial application load, all communication between the client and the server involves only and only bits of data.

2. Caching & Browser local storage
Implement your application such ensure caching on the level of the browser. Also, treat visibility properly so that if ever, you are using HTTP, intermediate proxies can cache your data. Then, for data that can be reused in the future, make use of the local storage.

3. Initial Application load
Normally, RIA are big in size compared to typical websites. So, at the initial application load, not all files are needed. I think it’s best not to load the entire application in one shot because several part might not be of use. Instead, insert junctures in your application that request the needed part from the server when needed. With JavaScript, it’s fairly easy to insert a script in DOM. Also, GWT does this well through a technique which they called Code Splitting

One very important aspect of Human Computer Interface is the enjoyment derived from using the software. So, at the same time, RIA must be at the same time useful and fun. I think that by optimizing bandwidth, ensuring a high level of interactivity and presenting data using rich widgets will allow to develop a good RIA which users will love.

Constaints

Though the technology exists for building RIAs, there are some constrains that cannot be avoided such as:

  • Heterogeneity
  • Search Engine Optimization
  • Browser Features
1.Heterogeneity

Browser Statistics

http://www.w3schools.com/browsers/browsers_stats.asp

Users on the other end make use of several browsers. We all know that browsers have incompatibilities. So, sometimes, we need to be good web developers and at the same time browser gurus to ensure consistency on all available browsers. Sometimes, when implementing some features of RIA, browser sniffing will be important. It’s boring because sometimes a particular feature must be implemented for several browsers if there is not a standard way to do it.

2.Search Engine Optimization

RIA will make use of asynchronous communication to request data from the server. The technology for achieving this is AJAX. There has always been a discussion whether not AJAX is SEO Friendly(Check this discussion here). However, Google has published a technique here to ensure that web crawlers can craw Ajaxified sites. They say it works and I’m sure it does but I’ve never used it.

3.Browser Features

RIA will always exist and so will normal websites do. Normal websites comply with browser features such as browser back/forward button, history, bookmarking. Normally, RIA are ajaxified internet application. Therefore, you’ll need to implement workarounds to ensure you don’t break those functionalities.

Development of RIA

There are several frameworks available for the development of RIAs. However, which one to choose? Personally, I’ve noticed that all RIA frameworks mitigate to maximize at least one of the three traits above. Some of the widely known frameworks are from Adobe technologies such as Flash or Flex, jQuery or Microsoft namely Microsoft Silverlight. (Here is a good list of RIA Frameworks) Check this to get an overview of RIA Statistics.

Future of RIA

I’m almost sure that the use of RIA will intensified in the coming years. Below is a study carried in 2006(obtained here):

Currently more and more companies are moving towards cloud computing(Saas) for their business solutions. Such as for accounting, some may be moving towards openERP or for CRM such as SalesForce. So, companies are now preferring Internet Application over Desktop applications. These Internet Application need to match those Desktop applications in terms of features and interactions. There comes RIAs to their rescue.