swift girls 9th_teaching_meeting20171016

32
SWIFT GIRLS (IOS) PART9 2017.10.16 by ⾃⼰開 API ⾃⼰串 4

Upload: -

Post on 29-Jan-2018

39 views

Category:

Software


0 download

TRANSCRIPT

  1. 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. 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. iosSwift Swift by 2 0 1 7 . 1 0 . 1 6
  3. 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. 4. S W I F T G I R L S ( I O S) ... , , , by :) 2 0 1 7 . 1 0 . 1 6
  5. 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. 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. 7. S W I F T G I R L S ( I O S) - PA R T 9 by A. nodeB. API API 2 0 1 7 . 1 0 . 1 6
  8. 8. A P I ? ? ? by 2 0 1 7 . 1 0 . 1 6
  9. 9. A P I ? ? ? by 2 0 1 7 . 1 0 . 1 6 > ...OZ
  10. 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. 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. 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. 13. by 2 0 1 7 . 1 0 . 1 6
  14. 14. S TA R T ! ! ! by 2 0 1 7 . 1 0 . 1 6
  15. 15. 1 : by 2 0 1 7 . 1 0 . 1 6
  16. 16. by node 2 0 1 7 . 1 0 . 1 6
  17. 17. by 2 0 1 7 . 0 2 . 0 6
  18. 18. by npm.init () npm install express (express pop) 2 0 1 7 . 1 0 . 1 6
  19. 19. by 2 0 1 7 . 1 0 . 1 6
  20. 20. by post man JSON Formatter 2 0 1 7 . 1 0 . 1 6
  21. 21. 2 : A P I by 2 0 1 7 . 1 0 . 1 6
  22. 22. by index.js node index.js () 2 0 1 7 . 1 0 . 1 6
  23. 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
  24. 24. by json1 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
  25. 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 json2
  26. 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. 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. 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. 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. 30. by var express = require('express'); // call express var app = express(); var port = 3000; //expressGET 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
  31. 31. 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
  32. 32. Q & A by 2 0 1 7 . 1 0 . 1 6