Runkeeper API access with HTTParty

So you want to access the Runkeeper’s API with HTTParty Gem. Well, this article is for you.

This is how I did it. Hope it helps you.

1. Register you web application and get your Client ID and Secret form Runkeeper’s Partner Portal Web Site

2. Generate your access token

To generate your access token, you have to run the following command in terminal window:
a. gem install launchy rack
b. Run bundle install
b. CLIENT_ID=“your Client ID” CLIENT_SECRET=“your Client Secret”
ACCESS_TOKEN_URL=“” token_generator

—- note: this is a one line command —-

c. The command will open a browser window with Runkeeper’s website login
d. Return to your terminal windows and your token will be displayed if your login was successful

Check this website where I found the procedure:

3. Add following line to add HTTParty gem in your Gemfile

gem ‘httparty’

From a terminal windows run the command: bundle install
This will install latest version of HTTParty Gem

4. I recommend you to check the following site for further information on HTTParty and Runkeeper’s API example calls


5. Modify your routes. Add a activity resource for this example. You can modify to suite your needs.

resources :activities

6. Create your controller with the following code:

class ActivitiesController < ApplicationController

def index
@user = Activity.grab_user
@activities = Activity.grab_activities


7. Create a environment variable with your token code

Add the following to your .bash_profile

export RUN_KEEPER_TOKEN=”xxxxxxxxxxxxxxxxxxxxxxxx”

replace “xxxxxxxxxxxxxxxxxxxxxxxx” with your token code

8. Create your model with the following code:

class Activity
include HTTParty

hostport = “
base_uri “http://#{hostport}”
format :json

def self.grab_user
headers ‘Authorization’ => ‘Bearer ENV[“RUN_KEEPER_TOKEN”]’, ‘Accept’ =>     “application/”

def self.grab_activities
headers ‘Authorization’ => ‘Bearer ENV[“RUN_KEEPER_TOKEN”]’, ‘Accept’ =>      “application/”


9. Create your view file as follows (index.html.erb):

<th>Start Time</th>
<th>Total Distance</th>
<% @activities.each do |activity| %>
<td><%= activity[“type”] %></td>
<td><%= activity[“start_time”].to_s %></td>
<td><%= activity[“total_distance”].to_i / 1000 %> Kms</td>
<td><%= activity[“duration”] %></td>
<% end %>


Keep in mind that for the HTTParty to work properly you have to change the headers depending on the resource you are accessing.

Please leave your comments.


Uber discloses data breach that may have affected 50,000 drivers


Uber suffered a data breach in 2014 that affected 50,000 Uber drivers across the U.S., the ride-sharing startup disclosed in a statement on Friday.

The company determined on September 17, 2014 that a third party could have accessed one of its databases. After Uber “changed the access protocols for the database” and looked into the situation, it learned through an investigation that someone apparently accessed one of its databases on May 13, 2014, wrote Katherine M Tassi, Uber’s managing counsel, privacy.

Supposedly, the information that may have been compromised included driver names and their driver license numbers, but the startup said that it is not aware of any “reports of actual misuse” of that data. The company said it will be contacting the drivers, issuing them memberships in identity-alert services and filing a lawsuit to obtain more information to learn who was the third party that accessed the database.


View original post 179 more words

WordPress Security Best Practices (Linux)

Los sitios de WordPress son bastante populares y por lo tanto, sufren de ataques informáticos con regularidad. En el siguiente link puedes encontrar un artículo de Rackspace que te puede ayudar a mejorar la seguridad de tu sitio WordPress.

WordPress sites are very popular nowadays and suffer from constant hacking attempts. The following link can help you secure your WordPress site.