Thursday, December 08, 2011

Emesene meets social networks

Hi all,

as you can see from the last work, a new interaction with Facebook has been made. Now you can receive you Facebook messages directly from your Facebook session in Emesene and clicking on the email icon you can access them.. This opens a lot of new possibilities to extend Emesene, making a full integration between Emesene, Google+ and Facebook, using the relative APIs written in Python, for example we can write a plugin for fetching events on social networks, take further info on our contacts and showing them in the profile box, set our social avatar as Emesene's avatar etc... Well, this post is for all developers interested in helping to grow up Emesene in this direction, so if you're one of them please join us. Here it is a screenshot of the last work:


This shows the login procedure for acquiring the token to get messages. This procedure is generic for every Facebook application, let's going to see how to do it :)

An introduction for developers

In this section I will explain how I developed the Facebook part, so you can see how to create your Facebook application and integrate it in Emesene easily. I' ve never worked with Google+ APIs, but should be something similar.

To use Facebook APIs you need to get a token from Facebook, logging in with your account. Before continue reading, I advice to read some doc about Facebook auth: http://developers.facebook.com/docs/authentication/ .

1. First of all we need Facebook APIs written in Python, I choosed pyfacebook and modified it. You can find them in /emesene/e3/jabber/pyfacebook.

2. Once you've get the API KEY and SECRET KEY from Facebook, you can use pyfacebook in this way:
client = Facebook(API_KEY, SECRET_KEY, oauth2 = True, app_id = API_KEY)
connection_url = client.login(REDIRECT_URL, required_permissions="read_mailbox, offline_access")
Specifying a REDIRECT_URL where you will be redirect when process finish its work and all permission our application needs.

3. Instead of using the default web browser, I created a customized web view that is able to intercept all the urls, so parsing them we can receive our token to use APIs. You can use it in this way:
dialog = extension.get_default('dialog')
dialog.web_window(title_string, connection_url , url_receive_callback)
where url_receive_callback is your function parsing every url searching for the token. Have a look at the method _on_social_request in /emesene/gui/gtkui/MainWindow.py

4. We can finally store the token in the user's configuration. I did this
self.session.config.facebook_token = token_found
5. Now it's time to develop a method to remove the token and restart the auth process.

That's is just an introduction, some modification on this component may happen, but won't interest the whole structure. We are waiting for your help dudes :)

Regards,

=.4.S.= Andrea Stagi

8 comments:

Anonymous said...

good work man!

it seem that you use gedit to develope emesene, is it possible by any chance to write a quick post of how to set it properly (plugins etc) to develop in python? it could be really helpfull for a lot of people

Thanks :-)
medeo TL

=.4.S.= said...

thanks ^^ well I use gedit with only the sintax highlighting, if I need to search for something around the code I use grep.. I don't need of some IDE.. what do you need in particular?

Fabio said...

cool, and what about this? https://github.com/emesene/emesene/issues/814

=.4.S.= said...

We need time and developers Fabio ^^ hope someone joins my idea and satisfies your request..

Fabio said...

some day ago I had a little idea, a version of emesene specialized for facebook, with groups managements retreive of personal status/avatar from contacts and integration with personal messages.. would be very cool

Anonymous said...

hi there

so my quiestion:

in 1.6.3 there was a plugin, the statushistory, and this plugin was able to show when a msn partner logged in/out, but also showed when a person was appear offline.

2.11.11 also have this plugin, but the new one dosnt show the appear offline thing.

can u make it work like that was in 1.6.3?

ty for the answer:)

Becca-Chan said...

Have you ever seem this?
http://windowsteamblog.com/windows_live/b/windowslive/archive/2011/12/14/anyone-can-build-a-windows-live-messenger-client-with-open-standards-access-via-xmpp.aspx

Adrián Solamente said...

http://www.process-one.net/en/blogs/article/details_on_msns_xmpp_server/