Archive

Over the last few days, I’ve been on the hunt for a good unlimited , free translation API. I’ve stumbled upon Glosbe.com, which does not require an API key, although they do mention it may be limited by request per IP to prevent abuse, and I’ll test that out on Monday.

But, as always, here is the C# code required to access this translation API:

Ever since Google started charging for it’s Translation API, and Microsoft put a 2 Million character limit on their free translation API, then you have to start looking outside of the USA for a free translation service. That’s when I discovered the Russian translation service provided by Yandex. They also do plenty of other languages, (Albanian Armenian Azerbaijani Belarusian Bulgarian Catalan Croatian Czech Danish Dutch Estonian Finnish French German Greek Hungarian Italian Latvian Lithuanian Macedonian Norwegian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swedish Turkish Ukrainian)

Offline Geolocation is an Android Library that can be used to determine the location of an Android phone when both GPS positioning and an Internet connection are unavailable.

This project is completely open source, you can download the source code for the Android App, and import it into your eclipse workspace. All we ask is that you tell us who you are and what you plan to do with the code before downloading it. You can then use the code freely, without any license restrictions, although we’d love it if you can give us credit in your final product.

How this App works, is it detects nearby cell towers, and compares the cell id, MCC, MNC and LAC codes against a SQLLite database of over 2 million known cell towers worldwide. It is designed to give you the best answer it can, although, the data is not exhaustive. This data will never be as accurate as GPS or Online Geolocation, but it serves as a good failover, whenever an Internet connection is unavailable.

OAUTH is an authentication system used by companies such as Google, Twitter, Vimeo, Linked in etc, and it is much more complex than basic authentication, but it really is just about exchanging data between your server and the authentication provider.

This is meant to be a “Hello World” example, showing an easy way to implement OAuth 2, without using any third party frameworks.

The example uses C# (ASPX), and Google API. I will be demonstrating a call to Google Analytics API, but any Google API works similarly. I can’t say the same for Twitter / Vimeo / LinkedIn, but the flow of data should be the same.

Prerequisites:

Some windows hosting to host the callback page

Sign up through the Google API Console to the Google Analytics API, and set up a client ID for Web Applications

Flow of actions overview:

The reason why OAuth is popular, is because it means that API consumers (i.e. you), don’t get to see user’s Google credentials. You never ask the user for their username and password, you send them to Google and Google enter their username and password on Google’s page. Google will then send you back “proof” that the username and password were correct, but will never tell you what the username and password was.

The first step, therefore is to send a user to google using a special link. A simple link like this does:

redirect_uri – You set this in your Google API, and it tells Google where to send the user after they have logged in.

scope – This sets which APIs you would like to use, In my case, Google Analytics.

Once the user signs into Google, then it’s up to some server-side code to interpret the response from Google, and use it to access Google’s APIs using the user’s credentials. This is where the callback script comes in, which is simply an ASPX page that is hosted on your server.

The steps that this script must do is:

1. Exchange the authorisation code provided by Google into a access token

2. Use the access token when calling Google’s API methods.

Let’s deal with the first step, the exchange of the authorisation code.

Google will redirect back to your URL with extra parameters, like this:

BAR files are the format for apps for the BlackBerry QNX range of devices (Z10, Q10, Playbook), it is basically a zip file, with a particular format. This is what you can see if you unzip a BAR file. This particular app is a BlackBerry Webworks / PhoneGap app.