SlideShare a Scribd company logo
1 of 32
Download to read offline
S W I F T G I R L S ( I O S)
PA R T 9
2 0 1 7 . 1 0 . 1 6
by 雅⽅方
⾃ ⼰ 開 A P I ⾃ ⼰ 串
4
S W I F T G I R L S ( I O S)
Swift Girls aims to give tools for girls and women to
build their ideas.
希望不斷推廣⽽而有更更多女⽣生⼀一同透過交流學習,⼀一起
了了解ios開發並能互相切磋,歡迎對Swift語⾔言有興趣的
⼀一起加入!
專為Swift新⼿手展開的第⼀一次”探勘“⾏行行動  
雅⽅方比女⼈人更更了了解女⼈人的雅⽅方
也是雅⽅方冰淇淋淋的雅⽅方
雅⽅方⽺羊⾁肉爐的雅⽅方
by 雅⽅方
2 0 1 7 . 1 0 . 1 6
S W I F T G I R L S ( I O S)
學習資源 線上網上各式各樣影片⽂文件無所不有!!!  
在這裡 可以有老師教練們給你來來問問題
可以有夥伴跟你⼀一起討論 (給你問⽩白癡的問題!?XD)
網上線上 都比不上實際⾯面對⾯面操作實作與立即性的討論
by 雅⽅方
看⼤大⼤大們debug 回家後你們也可以互相討論 ⾃自⼰己debug :)
重點是 能有⼀一起學習的夥伴 ⼀一起成長 :)
2 0 1 7 . 1 0 . 1 6
S W I F T G I R L S ( I O S)
深深感受到...  
以前看別⼈人寫程式會學到三成功⼒力力, 
經過⾃自⼰己下⾺馬打程式可學到七成功⼒力力,
教別⼈人寫程式,
by 雅⽅方
你會學到比你想像的功⼒力力還要多⼗十成! :)
2 0 1 7 . 1 0 . 1 6
S W I F T G I R L S ( I O S)
就是那些年年...
三個師兄師弟輕功⽔水上飄的感⼈人故事...
by 雅⽅方圖片來來源:http://kanema.pixnet.net/blog/post/33866276-150905-葉師⽗父練功之無徒⼀一⾝身輕
2 0 1 7 . 1 0 . 1 6
S W I F T G I R L S ( I O S) - PA R T 9
by 雅⽅方
發問解答⼯工具
1. Github(程式碼儲存庫), stackOverFlow
2. google ⼤大神
3. 社群發問
這次範例例Github:
https://github.com/Avonee/swift-girls-meetig_teachin
2 0 1 7 . 1 0 . 1 6
S W I F T G I R L S ( I O S) - PA R T 9
by 雅⽅方
A. 環境建置 

安裝node

B. 開API 

API實作
2 0 1 7 . 1 0 . 1 6
A P I ? ? ?
by 雅⽅方
2 0 1 7 . 1 0 . 1 6
A P I ? ? ? … 就 是 ⼀ 串 網 址
by 雅⽅方
2 0 1 7 . 1 0 . 1 6
— > 我 的 第 ⼀ 次 接 案 經 驗 ...OZ
A P I
by 雅⽅方
2 0 1 7 . 1 0 . 1 6
A P P L I C AT I O N P RO G R A M M I N G I N T E R FA C E
應⽤用程式之間溝通的窗⼝口,藉由此窗⼝口取得/提供對⽅方的服務
A P I
by 雅⽅方
2 0 1 7 . 1 0 . 1 6
基本三要素
• URLs(API 位置)

• methods(通常指HTML request ⽅法, POST, GET)

• form-data(API要求的資料輸入)
當使⽤用者提供API所需要的資訊時就能得到所需要的服務或資料
參參考:http://leeboy19890101-blog.logdown.com/posts/578758
R E S T F U L A P I
by 雅⽅方
2 0 1 7 . 1 0 . 1 6
POST v.s. GET ???
什什麼時候⽤用POST???
什什麼時候⽤用GET???
改 變 世 界
by 雅⽅方
2 0 1 7 . 1 0 . 1 6
S TA R T ! ! !
by 雅⽅方
2 0 1 7 . 1 0 . 1 6
⽬ 標 1 :
環 境 建 置
by 雅⽅方
2 0 1 7 . 1 0 . 1 6
by 雅⽅方
安裝node
2 0 1 7 . 1 0 . 1 6
by 雅⽅方
⾃自⼰己上網查!!!
2 0 1 7 . 0 2 . 0 6
by 雅⽅方
npm.init
終端機 …
(放套件)
npm install express
(express 最pop的框架)
2 0 1 7 . 1 0 . 1 6
by 雅⽅方
2 0 1 7 . 1 0 . 1 6
by 雅⽅方
除了了post man以外
JSON Formatter
看起來來比較帥
2 0 1 7 . 1 0 . 1 6
⽬ 標 2 :
開 A P I
by 雅⽅方
2 0 1 7 . 1 0 . 1 6
by 雅⽅方
開index.js
node index.js (執⾏行行)
2 0 1 7 . 1 0 . 1 6
by 雅⽅方
var express = require('express'); // call express
var app = express();
var port = 3000;
//監聽端⼝口
app.listen(port);
console.log('Magic happens on port ' + port);
2 0 1 7 . 1 0 . 1 6
by 雅⽅方
• 實作json範例例1
app.get('/member',function(req,res){
res.json([{name:'kevin',phone:0911111111},
{name:'kiki',phone:0922222222},{name:'vinvin',phone:
0933333333}])
})
2 0 1 7 . 1 0 . 1 6
by 雅⽅方
app.get('/account',function(req,res){
res.json([{ id: 'avon333456',task:'fight'},{ id:
'asfasdada12',task:'fight2'},{ id:
'asfasda23da',task:'fight3'},{ id:
'asfas123dada',task:'fight4'}])
})
2 0 1 7 . 1 0 . 1 6
• 實作json範例例2
by 雅⽅方
三種獲取參參數⽅方式
N O D E E X P R E S S
• req.body (post)
• req.params (/zzz/xxx)
• req.query (?xxx=…)
2 0 1 7 . 1 0 . 1 6
by 雅⽅方
• req.query (?xxx=…)
app.get('/member',function(req,res){
res.json({ message: 'hello! '+ req.query.name,
time:req.query.time
});
})
2 0 1 7 . 1 0 . 1 6
by 雅⽅方
• req.params (/zzz/xxx) 範例例1-1
app.get('/account/:id',function(req,res){
res.json({ id: req.params.id,task:'take a
shower',message:req.query.message})
})
那message?
2 0 1 7 . 1 0 . 1 6
by 雅⽅方
• req.params (/zzz/xxx) 範例例1-2
app.get('/account/:id',function(req,res){
res.json({ id: req.params.id,task:'take a
shower',message:req.query.message})
})
2 0 1 7 . 1 0 . 1 6
by 雅⽅方
完整範例例
var express = require('express'); // call express
var app = express();
var port = 3000;
//express獲得GET請求
app.get('/member',function(req,res){
res.json({ message: 'hello! '+ req.query.name,
time:req.query.time
});
// res.json([{name:'kevin',phone:0911111111},{name:'kiki',phone:0922222222},
{name:'vinvin',phone:0933333333}])
})
app.get('/account',function(req,res){
res.json([{ id: 'avon333456',task:'fight'},{ id: 'asfasdada12',task:'fight2'},
{ id: 'asfasda23da',task:'fight3'},{ id: 'asfas123dada',task:'fight4'}])
})
app.get('/account/:id',function(req,res){
res.json({ id: req.params.id,task:'take a shower',message:req.query.message})
})
//監聽端⼝口
app.listen(port);
console.log('Magic happens on port ' + port);
2 0 1 7 . 1 0 . 1 6
by 雅⽅方
參參考
https://scotch.io/tutorials/build-a-restful-api-using-node-and-express-4
http://xuyuan923.github.io/2014/10/10/node-tutorial-req/
2 0 1 7 . 1 0 . 1 6
Q & A
by 雅⽅方
2 0 1 7 . 1 0 . 1 6

More Related Content

Similar to Swift girls 9th_teaching_meeting20171016

HTML5移动WEB应用程序开发(PhoneGap)
HTML5移动WEB应用程序开发(PhoneGap)HTML5移动WEB应用程序开发(PhoneGap)
HTML5移动WEB应用程序开发(PhoneGap)amd6400
 
HTML5移动应用开发分享会(PhoneGap)
HTML5移动应用开发分享会(PhoneGap)HTML5移动应用开发分享会(PhoneGap)
HTML5移动应用开发分享会(PhoneGap)amd6400
 
Open Api&Sip
Open Api&SipOpen Api&Sip
Open Api&Sipcenwenchu
 
建築與都市的黏著劑:開放資料 (淡江建築 2016.10.9)
建築與都市的黏著劑:開放資料 (淡江建築 2016.10.9)建築與都市的黏著劑:開放資料 (淡江建築 2016.10.9)
建築與都市的黏著劑:開放資料 (淡江建築 2016.10.9)Tim Hong
 
Node Web开发实战
Node Web开发实战Node Web开发实战
Node Web开发实战fengmk2
 
2011/08/20跨平台行動應用程式使用者介面開發—以titanium mobile為例
2011/08/20跨平台行動應用程式使用者介面開發—以titanium mobile為例2011/08/20跨平台行動應用程式使用者介面開發—以titanium mobile為例
2011/08/20跨平台行動應用程式使用者介面開發—以titanium mobile為例Justin Lee
 
Mopcon2014 - 使用 Sinatra 結合 Ruby on Rails 輕鬆打造完整 Full Stack 網站加 API Service服務
Mopcon2014 - 使用 Sinatra 結合 Ruby on Rails 輕鬆打造完整 Full Stack 網站加 API Service服務Mopcon2014 - 使用 Sinatra 結合 Ruby on Rails 輕鬆打造完整 Full Stack 網站加 API Service服務
Mopcon2014 - 使用 Sinatra 結合 Ruby on Rails 輕鬆打造完整 Full Stack 網站加 API Service服務Mu-Fan Teng
 
Using google appengine_1027
Using google appengine_1027Using google appengine_1027
Using google appengine_1027Wei Sun
 
用JAX-RS和Jersey完成RESTful Web Services
用JAX-RS和Jersey完成RESTful Web Services用JAX-RS和Jersey完成RESTful Web Services
用JAX-RS和Jersey完成RESTful Web Servicesjavatwo2011
 
Node Web开发实战
Node Web开发实战Node Web开发实战
Node Web开发实战fengmk2
 
Using google appengine (2)
Using google appengine (2)Using google appengine (2)
Using google appengine (2)Wei Sun
 
美团点评技术沙龙011 - 移动app兼容性测试工具Spider
美团点评技术沙龙011 - 移动app兼容性测试工具Spider 美团点评技术沙龙011 - 移动app兼容性测试工具Spider
美团点评技术沙龙011 - 移动app兼容性测试工具Spider 美团点评技术团队
 
Python 工作坊 (NCTU)
Python 工作坊 (NCTU)Python 工作坊 (NCTU)
Python 工作坊 (NCTU)柏瑀 黃
 
美团点评技术沙龙06 - 提高移动端兼容性测试效率工具
美团点评技术沙龙06 - 提高移动端兼容性测试效率工具美团点评技术沙龙06 - 提高移动端兼容性测试效率工具
美团点评技术沙龙06 - 提高移动端兼容性测试效率工具美团点评技术团队
 
2009 Tw Oh Wretch Api
2009 Tw Oh Wretch Api2009 Tw Oh Wretch Api
2009 Tw Oh Wretch ApiJH Lee
 
智慧桌邊服務系統Smart restaurant service system
智慧桌邊服務系統Smart restaurant service system智慧桌邊服務系統Smart restaurant service system
智慧桌邊服務系統Smart restaurant service systemIttrainingIttraining
 
Build line notify bot by lotify and create client library by swagger 20200527
Build line notify bot by lotify and create client library by swagger 20200527Build line notify bot by lotify and create client library by swagger 20200527
Build line notify bot by lotify and create client library by swagger 20200527Jia Yu Lin
 
鼎鈞數位行銷App營運實務全攻略
鼎鈞數位行銷App營運實務全攻略鼎鈞數位行銷App營運實務全攻略
鼎鈞數位行銷App營運實務全攻略淳甫 鄭
 
HTML+COIMOTION 開發跨平台 app
HTML+COIMOTION 開發跨平台 appHTML+COIMOTION 開發跨平台 app
HTML+COIMOTION 開發跨平台 appBen Lue
 

Similar to Swift girls 9th_teaching_meeting20171016 (20)

HTML5移动WEB应用程序开发(PhoneGap)
HTML5移动WEB应用程序开发(PhoneGap)HTML5移动WEB应用程序开发(PhoneGap)
HTML5移动WEB应用程序开发(PhoneGap)
 
HTML5移动应用开发分享会(PhoneGap)
HTML5移动应用开发分享会(PhoneGap)HTML5移动应用开发分享会(PhoneGap)
HTML5移动应用开发分享会(PhoneGap)
 
Open Api&Sip
Open Api&SipOpen Api&Sip
Open Api&Sip
 
建築與都市的黏著劑:開放資料 (淡江建築 2016.10.9)
建築與都市的黏著劑:開放資料 (淡江建築 2016.10.9)建築與都市的黏著劑:開放資料 (淡江建築 2016.10.9)
建築與都市的黏著劑:開放資料 (淡江建築 2016.10.9)
 
Node Web开发实战
Node Web开发实战Node Web开发实战
Node Web开发实战
 
2011/08/20跨平台行動應用程式使用者介面開發—以titanium mobile為例
2011/08/20跨平台行動應用程式使用者介面開發—以titanium mobile為例2011/08/20跨平台行動應用程式使用者介面開發—以titanium mobile為例
2011/08/20跨平台行動應用程式使用者介面開發—以titanium mobile為例
 
Mopcon2014 - 使用 Sinatra 結合 Ruby on Rails 輕鬆打造完整 Full Stack 網站加 API Service服務
Mopcon2014 - 使用 Sinatra 結合 Ruby on Rails 輕鬆打造完整 Full Stack 網站加 API Service服務Mopcon2014 - 使用 Sinatra 結合 Ruby on Rails 輕鬆打造完整 Full Stack 網站加 API Service服務
Mopcon2014 - 使用 Sinatra 結合 Ruby on Rails 輕鬆打造完整 Full Stack 網站加 API Service服務
 
Using google appengine_1027
Using google appengine_1027Using google appengine_1027
Using google appengine_1027
 
用JAX-RS和Jersey完成RESTful Web Services
用JAX-RS和Jersey完成RESTful Web Services用JAX-RS和Jersey完成RESTful Web Services
用JAX-RS和Jersey完成RESTful Web Services
 
Node Web开发实战
Node Web开发实战Node Web开发实战
Node Web开发实战
 
42qu thrift1
42qu thrift142qu thrift1
42qu thrift1
 
Using google appengine (2)
Using google appengine (2)Using google appengine (2)
Using google appengine (2)
 
美团点评技术沙龙011 - 移动app兼容性测试工具Spider
美团点评技术沙龙011 - 移动app兼容性测试工具Spider 美团点评技术沙龙011 - 移动app兼容性测试工具Spider
美团点评技术沙龙011 - 移动app兼容性测试工具Spider
 
Python 工作坊 (NCTU)
Python 工作坊 (NCTU)Python 工作坊 (NCTU)
Python 工作坊 (NCTU)
 
美团点评技术沙龙06 - 提高移动端兼容性测试效率工具
美团点评技术沙龙06 - 提高移动端兼容性测试效率工具美团点评技术沙龙06 - 提高移动端兼容性测试效率工具
美团点评技术沙龙06 - 提高移动端兼容性测试效率工具
 
2009 Tw Oh Wretch Api
2009 Tw Oh Wretch Api2009 Tw Oh Wretch Api
2009 Tw Oh Wretch Api
 
智慧桌邊服務系統Smart restaurant service system
智慧桌邊服務系統Smart restaurant service system智慧桌邊服務系統Smart restaurant service system
智慧桌邊服務系統Smart restaurant service system
 
Build line notify bot by lotify and create client library by swagger 20200527
Build line notify bot by lotify and create client library by swagger 20200527Build line notify bot by lotify and create client library by swagger 20200527
Build line notify bot by lotify and create client library by swagger 20200527
 
鼎鈞數位行銷App營運實務全攻略
鼎鈞數位行銷App營運實務全攻略鼎鈞數位行銷App營運實務全攻略
鼎鈞數位行銷App營運實務全攻略
 
HTML+COIMOTION 開發跨平台 app
HTML+COIMOTION 開發跨平台 appHTML+COIMOTION 開發跨平台 app
HTML+COIMOTION 開發跨平台 app
 

Swift girls 9th_teaching_meeting20171016

  • 1. S W I F T G I R L S ( I O S) PA R T 9 2 0 1 7 . 1 0 . 1 6 by 雅⽅方 ⾃ ⼰ 開 A P I ⾃ ⼰ 串 4
  • 2. S W I F T G I R L S ( I O S) Swift Girls aims to give tools for girls and women to build their ideas. 希望不斷推廣⽽而有更更多女⽣生⼀一同透過交流學習,⼀一起 了了解ios開發並能互相切磋,歡迎對Swift語⾔言有興趣的 ⼀一起加入! 專為Swift新⼿手展開的第⼀一次”探勘“⾏行行動   雅⽅方比女⼈人更更了了解女⼈人的雅⽅方 也是雅⽅方冰淇淋淋的雅⽅方 雅⽅方⽺羊⾁肉爐的雅⽅方 by 雅⽅方 2 0 1 7 . 1 0 . 1 6
  • 3. S W I F T G I R L S ( I O S) 學習資源 線上網上各式各樣影片⽂文件無所不有!!!   在這裡 可以有老師教練們給你來來問問題 可以有夥伴跟你⼀一起討論 (給你問⽩白癡的問題!?XD) 網上線上 都比不上實際⾯面對⾯面操作實作與立即性的討論 by 雅⽅方 看⼤大⼤大們debug 回家後你們也可以互相討論 ⾃自⼰己debug :) 重點是 能有⼀一起學習的夥伴 ⼀一起成長 :) 2 0 1 7 . 1 0 . 1 6
  • 4. S W I F T G I R L S ( I O S) 深深感受到...   以前看別⼈人寫程式會學到三成功⼒力力,  經過⾃自⼰己下⾺馬打程式可學到七成功⼒力力, 教別⼈人寫程式, by 雅⽅方 你會學到比你想像的功⼒力力還要多⼗十成! :) 2 0 1 7 . 1 0 . 1 6
  • 5. S W I F T G I R L S ( I O S) 就是那些年年... 三個師兄師弟輕功⽔水上飄的感⼈人故事... by 雅⽅方圖片來來源:http://kanema.pixnet.net/blog/post/33866276-150905-葉師⽗父練功之無徒⼀一⾝身輕 2 0 1 7 . 1 0 . 1 6
  • 6. S W I F T G I R L S ( I O S) - PA R T 9 by 雅⽅方 發問解答⼯工具 1. Github(程式碼儲存庫), stackOverFlow 2. google ⼤大神 3. 社群發問 這次範例例Github: https://github.com/Avonee/swift-girls-meetig_teachin 2 0 1 7 . 1 0 . 1 6
  • 7. S W I F T G I R L S ( I O S) - PA R T 9 by 雅⽅方 A. 環境建置 安裝node B. 開API API實作 2 0 1 7 . 1 0 . 1 6
  • 8. A P I ? ? ? by 雅⽅方 2 0 1 7 . 1 0 . 1 6
  • 9. A P I ? ? ? … 就 是 ⼀ 串 網 址 by 雅⽅方 2 0 1 7 . 1 0 . 1 6 — > 我 的 第 ⼀ 次 接 案 經 驗 ...OZ
  • 10. A P I by 雅⽅方 2 0 1 7 . 1 0 . 1 6 A P P L I C AT I O N P RO G R A M M I N G I N T E R FA C E 應⽤用程式之間溝通的窗⼝口,藉由此窗⼝口取得/提供對⽅方的服務
  • 11. A P I by 雅⽅方 2 0 1 7 . 1 0 . 1 6 基本三要素 • URLs(API 位置) • methods(通常指HTML request ⽅法, POST, GET) • form-data(API要求的資料輸入) 當使⽤用者提供API所需要的資訊時就能得到所需要的服務或資料 參參考:http://leeboy19890101-blog.logdown.com/posts/578758
  • 12. R E S T F U L A P I by 雅⽅方 2 0 1 7 . 1 0 . 1 6 POST v.s. GET ??? 什什麼時候⽤用POST??? 什什麼時候⽤用GET???
  • 13. 改 變 世 界 by 雅⽅方 2 0 1 7 . 1 0 . 1 6
  • 14. S TA R T ! ! ! by 雅⽅方 2 0 1 7 . 1 0 . 1 6
  • 15. ⽬ 標 1 : 環 境 建 置 by 雅⽅方 2 0 1 7 . 1 0 . 1 6
  • 16. by 雅⽅方 安裝node 2 0 1 7 . 1 0 . 1 6
  • 18. by 雅⽅方 npm.init 終端機 … (放套件) npm install express (express 最pop的框架) 2 0 1 7 . 1 0 . 1 6
  • 19. by 雅⽅方 2 0 1 7 . 1 0 . 1 6
  • 20. by 雅⽅方 除了了post man以外 JSON Formatter 看起來來比較帥 2 0 1 7 . 1 0 . 1 6
  • 21. ⽬ 標 2 : 開 A P I by 雅⽅方 2 0 1 7 . 1 0 . 1 6
  • 22. by 雅⽅方 開index.js node index.js (執⾏行行) 2 0 1 7 . 1 0 . 1 6
  • 23. by 雅⽅方 var express = require('express'); // call express var app = express(); var port = 3000; //監聽端⼝口 app.listen(port); console.log('Magic happens on port ' + port); 2 0 1 7 . 1 0 . 1 6
  • 25. by 雅⽅方 app.get('/account',function(req,res){ res.json([{ id: 'avon333456',task:'fight'},{ id: 'asfasdada12',task:'fight2'},{ id: 'asfasda23da',task:'fight3'},{ id: 'asfas123dada',task:'fight4'}]) }) 2 0 1 7 . 1 0 . 1 6 • 實作json範例例2
  • 26. by 雅⽅方 三種獲取參參數⽅方式 N O D E E X P R E S S • req.body (post) • req.params (/zzz/xxx) • req.query (?xxx=…) 2 0 1 7 . 1 0 . 1 6
  • 27. by 雅⽅方 • req.query (?xxx=…) app.get('/member',function(req,res){ res.json({ message: 'hello! '+ req.query.name, time:req.query.time }); }) 2 0 1 7 . 1 0 . 1 6
  • 28. by 雅⽅方 • req.params (/zzz/xxx) 範例例1-1 app.get('/account/:id',function(req,res){ res.json({ id: req.params.id,task:'take a shower',message:req.query.message}) }) 那message? 2 0 1 7 . 1 0 . 1 6
  • 29. by 雅⽅方 • req.params (/zzz/xxx) 範例例1-2 app.get('/account/:id',function(req,res){ res.json({ id: req.params.id,task:'take a shower',message:req.query.message}) }) 2 0 1 7 . 1 0 . 1 6
  • 30. by 雅⽅方 完整範例例 var express = require('express'); // call express var app = express(); var port = 3000; //express獲得GET請求 app.get('/member',function(req,res){ res.json({ message: 'hello! '+ req.query.name, time:req.query.time }); // res.json([{name:'kevin',phone:0911111111},{name:'kiki',phone:0922222222}, {name:'vinvin',phone:0933333333}]) }) app.get('/account',function(req,res){ res.json([{ id: 'avon333456',task:'fight'},{ id: 'asfasdada12',task:'fight2'}, { id: 'asfasda23da',task:'fight3'},{ id: 'asfas123dada',task:'fight4'}]) }) app.get('/account/:id',function(req,res){ res.json({ id: req.params.id,task:'take a shower',message:req.query.message}) }) //監聽端⼝口 app.listen(port); console.log('Magic happens on port ' + port); 2 0 1 7 . 1 0 . 1 6
  • 32. Q & A by 雅⽅方 2 0 1 7 . 1 0 . 1 6