获取Jawbone UP中的个人数据(二)非官方API , part 1

1. 概述和登陆

从Jawbone网站上,能够下载UP的个人数据,但是这个数据是以天为单位的汇总数据,如果我们需要更精细的数据,就必须通过程序获取。

Jawbone官方网站宣称已经提供开发API,用于与合作方应用之间进行数据交换。但是这个API在网上见不到。我辈苦逼的码农想玩玩自己的数据,只好另想办法。

Eric Blue曾经于2011年11月发表过一篇博文jawbone-up-api-discovery,介绍了他通过网络侦听Jawbone UP应用与服务器之间的通讯,破解出的一些非官方API,这些API可以用于获得用户自己的运动数据。时过境迁,Jawbone UP硬件已经更新换代至UP 2,手环版本为6-1.0.20,手机应用软件也已经升级到了2.6.8版本,Server端版本已经更新至1.34。Eric Blue公布的API部分内容已经过时。

下面的API是对Jawbone UP的Android版本进行了反编译所得到的,并借鉴了Eric Blue的方法,通过对Jawbone UP应用发出的请求进行侦听以确认,错误在所难免。这些API包括:

  • 两种login方法
  • UP进入后首屏信息显示所使用的:user score 和 social feeds
  • 获取不同类型的用户时间:
  • 详细记录:包括move, sleep, workout、mood、meal
  • 统计结果数据
  • 用户Profile
  • 朋友列表

各位玩的开心!

客户端请求基本说明

典型的 Jawbone UP 客户端请求形式如下,其中形如 v.1.34 的版本部分用于指明所需的Server端服务版本号,此信息可以省略:

https://jawbone.com/nudge/api/...
https://jawbone.com/nudge/api/v.1.34/...

在进行其他访问之前,必须先登录。正确登录之后,只需在每次请求的HTTP中,将认证时的所获得Token值设置到 HTTP Header:**x-nudge-token** 里,即可保持会话。

x-nudge-token : 1BkkscbY2RvUUQXF9TewzzDEEuGrKl7nJIuimAfcp8E

用户登录

Eric Blue 提到的登录方式 "**user/signin/login**" 方法仍然可用。不过在新的UP客户端版本中,还能够通过 “**users/login**” API进行登陆。

利用 user/signin/login 登陆

Request:

POST    
https://jawbone.com/nudge/api/user/signin/login

Params:

'email': email, 
'pwd':  password, 
'service': 'nudge'

Return :

Token 值为 JSON 内容中最下端的 "token" : "un_ZHV8Uiq1pyJCPnqCljjDEEuGrKl7nURWQYUScC6E"

用户 XID 值取 "user"."xid” : "RGaCBFg9CsDYVvm2kchbcw"

完整JSON示例如下:

{
    "newly": false, 
    "user": {
        "last_name": "VisHealth", 
        "uid": 37291881, 
        "image": "user/image/i/51b4916b03eb185d1c1948a5_RGaCBFg9CsDYVvm2kchbcw_137078820345_2781804_photo.jpeg", 
        "time_removed": 0, 
        "basic_info": {
            "weight": 56.2, 
            "dob": "1976-06-09", 
            "gender": "female", 
            "metric": 1, 
            "height": 1.58, 
            "locale": "zh-cn"
        }, 
        "share_move": true, 
        "birth_day": "09", 
        "text_1": "", 
        "first_name": "Tester", 
        "xid": "RGaCBFg9CsDYVvm2kchbcw", 
        "smart_alarm": {
            "stopTimeMinsPastMidnight": 390, 
            "dayMask": 62, 
            "enable": true, 
            "startTimeMinsPastMidnight": 370
        }, 
        "apps": [
            {
                "xid": "bVvQvURXOKc", 
                "share": true
            }, 
            {
                "xid": "__3Ao7ntG68", 
                "share": true
            }
        ], 
        "share_eat": false, 
        "birth_month": "06", 
        "type": 0, 
        "email": "iasc@163.com", 
        "birth_year": "1976", 
        "band_name": "iasc's jawbone up", 
        "up_goals": {
            "move": {
                "steps": 10000, 
                "workout_time": null
            }, 
            "sleep": {
                "total": 27000, 
                "bedtime": null, 
                "deep": null
            }, 
            "meals": {
                "carbs": null, 
                "fiber": null, 
                "sodium": null, 
                "sugar": null, 
                "calcium": null, 
                "unsat_fat": null, 
                "cholesterol": null, 
                "protein": null, 
                "sat_fat": null
            }
        }, 
        "first": "Tester", 
        "share_mood": true, 
        "primary_address": {
            "city": "", 
            "xid": "P9Q5vjiI-M0", 
            "country": "CN", 
            "zipcode": "", 
            "state": "", 
            "street_1": "", 
            "street_2": ""
        }, 
        "share_sleep": false, 
        "power_nap": {
            "use_optimal_duration": 0, 
            "custom_duration": 2400, 
            "maximum_duration": 3600
        }, 
        "active_alert": {
            "stopTimeMinsPastMidnight": 1020, 
            "threshold": 0, 
            "durationMins": 60, 
            "type": 1, 
            "startTimeMinsPastMidnight": 480
        }, 
        "last": "VisHealth", 
        "name": "Tester VisHealth", 
        "gender": "female", 
        "profile_privacy": "friends", 
        "data_2": 0, 
        "data_1": 0, 
        "flags": 1, 
        "time_created": 1370439133, 
        "mail_opts": {
            "mail_opt_in_new_products": null, 
            "mail_opt_in": null, 
            "mail_opt_in_products_owned_updates": null, 
            "mail_opt_in_customer_surveys": null, 
            "mail_opt_in_deals_n_promotions": null
        }, 
        "goals": {
            "move": 3500, 
            "sleep": 21600, 
            "eat": 2
        }
    }, 
    "token": "un_ZHV8Uiq1pyJCPnqCljjDEEuGrKl7nURWQYUScC6E", 
    "rc": 0
}   

利用 users/login 登陆

users/login 是目前Jawbone UP客户端采用的登录方式,由于其将用户密码进行 SHA-1 之后再传递,所以更加安全。

登陆页面

Request:

POST
https://jawbone.com/nudge/api/users/login

Params:

'email' : email,
'hash_pwd' : hash #将 password 进行 SHA-1 之后,再转换成 HEX 格式

Return :

Token 值为 JSON 内容中的 "data"."session_uid" : "1BkkscbY2RvUUQXF9TewzzDEEuGrKl7nJIuimAfcp8E"

用户 XID 值为 "data"."user"."xid" : "RGaCBFg9CsDYVvm2kchbcw"

完整JSON示例如下:

{
    "meta": {
        "message": "OK", 
        "code": 200, 
        "time": 1371960908
    }, 
    "data": {
        "session_uid": "1BkkscbY2RvUUQXF9TewzzDEEuGrKl7nJIuimAfcp8E", 
        "config": {
            "i18n": null, 
            "configuration": {
                "twitter_character_count": 24, 
                "system_message": ""
            }, 
            "features": {
                "up_food_gallery": [
                    "off", 
                    null
                ], 
                "up_twitter_share": [
                    "on", 
                    null
                ], 
                "up_fooditem_search_typeahead": [
                    "on", 
                    null
                ], 
                "up_app_gallery": [
                    "off", 
                    null
                ], 
                "up_addressbook_import": [
                    "on", 
                    null
                ], 
                "up_daily_dashboards": [
                    "off", 
                    null
                ], 
                "up_search": [
                    "on", 
                    null
                ], 
                "up_fb_share": [
                    "on", 
                    null
                ], 
                "system": [
                    "on", 
                    null
                ], 
                "up_cheers": [
                    "off", 
                    null
                ], 
                "barcode_search": [
                    "on", 
                    null
                ], 
                "up_twitter_import": [
                    "on", 
                    null
                ], 
                "up_twitter_friend_suggestions": [
                    "on", 
                    null
                ], 
                "up_fb_import": [
                    "on", 
                    null
                ], 
                "up_slideshow": [
                    "on", 
                    {}
                ], 
                "up_fb_friend_suggestions": [
                    "on", 
                    null
                ]
            }
        }, 
        "user": {
            "xid": "RGaCBFg9CsDYVvm2kchbcw", 
            "name": "Tester VisHealth", 
            "short_name": "Tester", 
            "image": "user/image/i/51b4916b03eb185d1c1948a5_RGaCBFg9CsDYVvm2kchbcw_137078820345_2781804_photo.jpeg", 
            "has_settings": true, 
            "last": "VisHealth", 
            "type": "user", 
            "first": "Tester"
        }
    }
}

待续。。。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值