惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tailwind CSS Blog
博客园 - Franky
博客园 - 司徒正美
Stack Overflow Blog
Stack Overflow Blog
GbyAI
GbyAI
Y
Y Combinator Blog
Microsoft Azure Blog
Microsoft Azure Blog
Blog — PlanetScale
Blog — PlanetScale
博客园 - 叶小钗
罗磊的独立博客
The GitHub Blog
The GitHub Blog
H
Help Net Security
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Engineering at Meta
Engineering at Meta
Martin Fowler
Martin Fowler
Spread Privacy
Spread Privacy
Google DeepMind News
Google DeepMind News
AWS News Blog
AWS News Blog
N
Netflix TechBlog - Medium
T
The Exploit Database - CXSecurity.com
云风的 BLOG
云风的 BLOG
小众软件
小众软件
aimingoo的专栏
aimingoo的专栏
Cyberwarzone
Cyberwarzone
T
Threatpost
T
Threat Research - Cisco Blogs
Recent Announcements
Recent Announcements
T
Tor Project blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Last Week in AI
Last Week in AI
L
Lohrmann on Cybersecurity
量子位
V
V2EX
V
Vulnerabilities – Threatpost
L
LINUX DO - 热门话题
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Proofpoint News Feed
I
Intezer
Schneier on Security
Schneier on Security
雷峰网
雷峰网
B
Blog RSS Feed
Jina AI
Jina AI
爱范儿
爱范儿
Attack and Defense Labs
Attack and Defense Labs
Google DeepMind News
Google DeepMind News
M
MIT News - Artificial intelligence
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Palo Alto Networks Blog
美团技术团队
博客园 - 【当耐特】

夜行人

回家路上 第一期的直播演示项目 震动检测器 正能量 在线参观CodeLab Neverland 发布 CodeLab Adapter 3.3.1 DynamicTable 之 纸糊方向盘 CodeLab DynamicTable: 一个可实施的技术方案 CodeLab Insight 发布 Alpha 版 情人节 Home Assistant 周报 && IoT 周报 (02) Joplin: 关注隐私的 Evernote 开源替代软件 浏览器的未来与 Web 传感器 Home Assistant 周报 && IoT 周报 (01) 百宝箱(01) 论自由 介绍 WebThings Home Assistant 周报 && iot 周报 (00) 百宝箱(00) 毛姆读书心得 传世之作 周末徒步 CodeLab Adapter ❤️ Jupyter/Python 航班 躲雨 夏令营途中 [译]思想--作为一种技术 The future of coding 美国之行 三门问题的程序模拟 从Python转向Pharo https://blog.just4fun.site/post/iot/iot-open-source-projects/ Python异步编程笔记 https://blog.just4fun.site/post/iot/iot-open-source-hardware-community/ 万物积木化开发者社区 CodeLab ❤️ Blender Scratch3技术分析之云变量 API(第7篇) [译]对管道(Pipes)的偏爱 [译]提出正确的问题比得到正确答案更重要 蓝牙设备与Scratch3.0 创建你的第一个Scratch3.0 Extension Scratch3技术分析之项目内部数据(第6篇) Scratch3技术分析之社区 API(第5篇) Scratch3技术分析之项目主页API(第3篇) Scratch3技术分析之静态资源API(第2篇) Scratch3.0、micro:bit与Windows7 https://blog.just4fun.site/post/iot/zerynth-vs-micropython/ 核聚变、方所与半宅空间 可视化编程为何是个糟糕的主意 codelab.club周末聚会 关于codelab.club '下一件大事'是一个房间 Hungry Robot - Eat everything 编程作为一种思考方式 今日简史 史蒂夫·乔布斯传 罗素自选文集 https://blog.just4fun.site/post/edx/tianjin-scratch-ai/ https://blog.just4fun.site/post/edx/richie-cms-openedx/ 徒步武功山 WebUSB与micro:bit 积木化编程与3D场景 夜宿武功山顶 scratch3-adapter接入优必选Alpha系列机器人 https://blog.just4fun.site/post/edx/video-migration-note/ scratch3-adapter重构笔记 https://blog.just4fun.site/post/edx/edx-community-members/ 两种硬件编程风格的比较 使用micro:bit自制PPT翻页笔 柏拉图对话集 scratch3.0 + micro:bit 七月电影放映计划 非营利组织的管理 Screenly--用树莓派让任何屏幕变为可编程的数字标牌 以最佳实践开始你的Django项目 micro:bit与事件驱动 为Scratch3.0设计的插件系统(上篇) OCR应用一例 近两年读过的一些好书 blockly开发之使用python驱动浏览器中的turtle(2) 牛顿新传 文学理论入门 逻辑的引擎 人生的意义 blockly开发之生成并运行js代码(1) blockly开发之hello world(0) micro:bit使用笔记 神器之Termux https://blog.just4fun.site/post/iot/micropython-notes/ Cozmo what is this Scratch的前世今生 下段旅程 我行在远方 爆裂 途中杂记 https://blog.just4fun.site/post/edx/open-edx-startup/ cozmo系列之入门 - 有性格且可编程的机器人 PaperWeekly开发笔记 创业二三事 blockly与结对编程
Scratch3技术分析之User API(第4篇)
种瓜 · 2019-01-15 · via 夜行人

文章目录

我们关心以下User API:

  • 注册
  • 登陆
  • 验证邮件
  • 用户消息

注册

1
2
username: api_test2
password: api_test2llk

第1步

GET https://scratch.mit.edu/accounts/check_username/api_test2/

返回: [{"username": "api_test2", "msg": "valid username"}]

第2步

没有数据交互

第3步

接收来自 Scratch 团队的更新通知可勾选。

1
GET https://scratch.mit.edu/accounts/check_email/?email=wuwenjie718%40gmail.com

返回[{"msg": "valid email", "email": "wuwenjie718@gmail.com"}]

第4步

POST https://scratch.mit.edu/accounts/register_new_user/

以Form Data提交

1
username=api_test2&password=api_test2llk&birth_month=1&birth_year=2001&gender=male&country=China&email=wuwenjie718%40gmail.com&subscribe=true&is_robot=false&csrfmiddlewaretoken=f33VDWVgfOhFVK3nwDK4hNEDVFmjHOO3

其中csrfmiddlewaretoken是通过GET https://scratch.mit.edu/csrf_token/请求得到(set-cookie)

验证邮件

邮件验证链接为:

https://scratch.mit.edu/accounts/email_verify/WzQwNDQ2ODAxLCJ3dXdlbmppZTcxOEBnbWFpbC5jb20iLHRydWVd:1gjHzZ:N5Rkcd9rnux1qFAVQtExCFV06gw/?isRegistration=true

验证完成之后:

Scratch的易用性做得非常好。整个产品逻辑很清晰。点击ok,let's go 则进入https://scratch.mit.edu/社区。

验证完邮件后,我们还会收到一封邮件:

登陆

POST https://scratch.mit.edu/accounts/login/

请求的json数据为:{"username":"api_test2","password":"api_test2llk","useMessages":true}

后端返回: [{"username": "api_test2", "num_tries": 1, "success": 1, "msg": "", "messages": [], "id": 40446801}]

登陆之后会立刻请求GET https://scratch.mit.edu/session/

返回:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{
  "user": {
    "id": 40446801,
    "banned":  false,
    "username": "api_test2",
    "token": "12b89f5b950549ef927c2df5f5ee6fa3:u1PE_y4qIYis1GA2VY_D-RWWndw",
    "thumbnailUrl": "//cdn2.scratch.mit.edu/get_image/user/default_32x32.png",
    "dateJoined": "2019-01-15T06:14:28",
    "email": "wuwenjie718@gmail.com"
    
  },
  "permissions": {
    "admin": false,
    "scratcher": false,
    "new_scratcher": true,
    "social": true,
    "educator": false,
    "educator_invitee": false,
    "student": false
  },
  "flags": {
    "must_reset_password": false,
    "must_complete_registration": false,
    "has_outstanding_email_confirmation": false,
    "show_welcome": true,
    "confirm_email_banner": true,
    "unsupported_browser_banner": true
  }
}

这里包含了更为全面的用户画像信息。

如果登陆失败,则返回403错误:

[{"username": "api_test2", "num_tries": 1, "success": 0, "msg": "\u8d26\u53f7\u6216\u5bc6\u7801\u9519\u8bef\u3002", "messages": [], "id": null}]

用户消息

Scratch的新用户引导是做得非常好的。

欢迎来到Scratch!标签栏给出了新用户入门引导链接。

新用户会收到一条消息:GET https://api.scratch.mit.edu/users/api_test2/messages/count

后台返回: {"count":1}

消息接口目前是定时轮询。

消息详情

GET https://api.scratch.mit.edu/users/api_test2/messages?limit=40&offset=0

后台返回:

1
[{"id":20423966,"datetime_created":"2019-01-15T06:14:28.000Z","actor_username":"api_test2","actor_id":40446801,"type":"userjoin"}]

目前我们的消息还很少,不好分析,之后我们再来专门分析这部分。

由于个人中心之类的页面,Scratch团队还没有迁移到新版的前端中,所以我们暂不分析。为了追求接口稳定性,我们待官方完成这部分工作后,再做分析。