GithubHelp home page GithubHelp logo

fitbit-summary's Introduction

[Fitbit-Summary]Fitbitを使った健康報告バッチ

毎晩23時にFitbit APIを使って健康情報をTwitterに投稿する。プログラムの実行は、サーバのcronで登録する。

Fitbit Web API

https://dev.fitbit.com/build/reference/web-api/

エントリーポイント

# linux
python3 ./main.py
# windows
python ./main.py

Dependencies

requests

pip install requests

pytweet(githubからクローン)

プロジェクトの直下にクローン。

git clone https://github.com/zenryokukun/pytweet.git

モジュール更新時はgit pullすること。メディア・アップロードは追加され次第対応予定なので、 近いうちに更新する予定。

cd pytweet
git pull

スクリプトについて

  • main.py エントリーポイント
  • api.py Fitbit Web APIの実行
  • graph.py 心拍数やSpO2データをグラフ化し画像にする
  • pytweet/ Twitter API V2対応の外部パッケージ。(https://github.com/zenryokukun/pytweet.git)

必要なファイル

conf.json fitbit conf file

{
  "client_id": "your-client-id",
  "client_secret": "your-client-secret",
  "access_token": "your-access-token",
  "refresh_token": "your-refresh-token",
  "redirect_uri": "your-redirect-url",
  "user_id": "your-user-id",
  "scope": "your-scope"
}

client_id,access_token,refresh_tokenの3点あれば動きます。

twitter_conf.json twitter conf file

{
  "API_KEY": "MY-API-KEY",
  "API_SECRET": "MY-API-SECRET",
  "BEARER": "MY-BEARER",
  "ACCESS_TOKEN": "MY-ACCESS-TOKEN",
  "ACCESS_SECRET": "MY-ACCESS-SECRET"
}

出力されるファイル

  • heart-spo.png tweetする画像

cron(備忘)

登録スクリプト

ログインスクリプトが流れないのでコマンドもフルパスで登録

/usr/bin/python3 /home/crypto/fitbit/main.py

スケジュール

曜日
0-59 0-23 1-31 1-12 0-7
  • 曜日は0,7が日曜日。
  • *は全ての値を設定したことになる。分を*にすると毎分になる。
  • ex: 0 2 * * * 毎日2時00分に実行
  • ex: * 2 * * * 毎日2時の毎分実行

fitbit-summary's People

Contributors

zenryokukun avatar

Stargazers

 avatar Nakajima avatar Hiroyuki Kuromiya avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.