Showing posts with label twitter. Show all posts
Showing posts with label twitter. Show all posts

Friday, July 27, 2012

API accesses

Its great how far technology has advanced in terms of providing access. Now-a-days one gets all the APIs to access any online application. They even document it so precisely and accurately. And if one wants a wrapper for languages like Ruby, Python, Perl and PHP then that is readily available as well.

Well I'm going to shortly discuss about some Gems I have used to access these APIs.

The first Gem that I purely awesome is the 'omniauth' Gem. It has all the routines necessary to build add-ons for other Omniauth Plugins. You might need to read more about oauth to get an idea. I managed to use the plugins - omniauth-twitteromniauth-facebookomniauth-linkedin and omniauth-instagram with this Gem. And its so easy.

You will have to add an omniauth.rb file in the initializers for starters.


Rails.application.config.middleware.use OmniAuth::Builder do 
 provider :linkedin, LINKEDIN_CONFIG['api_key'], LINKEDIN_CONFIG['secret_key']   
 provider :twitter, TWITTER_CONFIG['consumer_key'], TWITTER_CONFIG['consumer_secret'] 
 provider :facebook, FACEBOOK_CONFIG['app_id'], FACEBOOK_CONFIG['secret'], :scope => FACEBOOK_CONFIG['scope'], :display => 'popup' 
 provider :instagram, INSTAGRAM_CONFIG['client_id'], INSTAGRAM_CONFIG['client_secret'], :scope => INSTAGRAM_CONFIG['scope'] 
end


It might be a good idea to insert these configuration files on deployment, rather than put them in the git.

The you will have to call something like

current_user.services.create!(
 :provider => auth['provider'], 
 :uid => auth['uid'], 
 :token => (auth['credentials']['token'] rescue nil), 
 :secret => (auth['credentials']['secret'] rescue nil))

Better add in lots of Exception handling.

This is the authorization part. The idea is generally at the end of the authentication, you will get a token which you should use for further requests to these services. To access the data from these services, one would have to use other Gems and then pass the auth_token (and auth_secret).

The gems used to access the data are :
fb_graph Gem for Facebook
twitter Gem for Twitter
linkedin Gem for Linked In
instagram Gem for Instagram

Try them out. You will love them.

Wednesday, June 24, 2009

The Face of the Web

It changes everyday. Trends change and so does the people who use them. We have all seen what a simple application like twitter did to the community. It made the community addicted to it. And millions of people find it important to use this service as a medium of communication. I still remember the incident when twitter was able to save a life.

The term 'service' is a very subtle but important thing to note here. Saumitri helped me understand the true role of an application. An application can be a utility or a service. Utility is something a user would come for a specific purpose. He might or might not choose to return to the application. But a service is something that pulls the user and makes him do stuff with the application. The success of twitter lies in the fact that it is a service. And this service has a large amount of marketting, driven by the common user. People who are part of this application sell the application. They are fully in control of what they want to publish, which might be even advertising themselves, and they have a greater reach.

Now applications like twitpic have solved something that twitter did not have. Store a picture in twitpic and we will post a link to your twitter account. Twitter having an open API made things easier. Think of the time when twitter would allow you to attach images from the main application itself. Twitpic becomes irrelevant. Twitpic for me is then a utility. It uses something and routes traffic into the application. Intelligent and effective but for a short term.

Most of those great applications, if you notice, have a very simple idea as their core. They facilitate a certain action and they render them in a unique style. Once we get used to a style, it is pretty hard to revert or use another one. The crux is not to develop UI intensive applications which serve multiple purposes, but to have an application simple enough which fulfils a purpose in a simple fashion.

These kinds of ideas are hard to come by. They just click at once. I am on the look out for an idea that would change my world and one that would leave a footprint on the net.