LoginSignup
8
7

More than 5 years have passed since last update.

EC2上にfitbit環境をつくる

Last updated at Posted at 2014-10-16

EC2上のrubyやphpからfitbitのデータを取得できる環境を構築するまでのメモ。

fitbitとは
http://www.fitbit.com/jp/home

0. instance立ち上げ〜ruby gem準備まで

EC2上にinstanceを立ち上げる。
とりあえず、お試しならt2.microでも良いかも。

rubyのバージョンを確認し、必要ならgemの環境を整える。

■ Ruby環境

  1. fitgem
$ gem install fitgem
  1. Set Up a Config File to Hold OAuth Tokens
$ curl https://gist.githubusercontent.com/whazzmaster/5322902/raw/aa4293a9eb288d2096840a05b35a1ecf829defc1/.fitgem.yml > .fitgem.yml

.fitgem.ymlの以下の場所を書き換える
rb:.fitgem.yml
oauth:
consumer_key: "your consumer key here"
consumer_secret: "your consumer secret here"

  1. Login and Get OAuth Tokens
$ curl https://gist.githubusercontent.com/whazzmaster/5322902/raw/4439e2d577567d280856a2d77cef7b824a851cd1/test-fitgem.rb > test-fitgem.rb
$ chmod +x test-fitgem.rb

$ ./test-fitgem.rb

アプリのアクセス許可を聞かれるので、指定のURLをひらいてアクセスを許可する

■ PHP環境

$ sudo yum install php-common php-devel php-cli php-pear
$ sudo yum install pcre-devel
$ sudo yum install libcurl-devel 
$ sudo pecl channel-update pecl.php.net
$ sudo pecl install oauth-0.99.9

$ sudo vim /etc/php.d/oauth.ini
$ cat /etc/php.d/oauth.ini
; Enable oauth extension module
extension=oauth.so

○example source(dev.fitbit.com)

$ curl https://wiki.fitbit.com/download/attachments/884784/completeAuthorization.php?version=2&modificationDate=1297797897000&api=v2 >  completeAuthorization.php

○ FitbitPHP

$ git clone https://github.com/heyitspavel/fitbitphp.git
8
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
7