Upgrade to Pro — share decks privately, control downloads, hide ads and more …

kintoneで楽々交通費精算!駅すぱあとWebサービス連携ハンズオン #kintonedev...

kintoneで楽々交通費精算!駅すぱあとWebサービス連携ハンズオン #kintonedevcamp / 20180802

HikaruMaruyama

August 03, 2018
Tweet

More Decks by HikaruMaruyama

Other Decks in Programming

Transcript

  1. ຊ೔ͷΞδΣϯμ • kintoneͰަ௨අਫ਼ࢉΞϓϦΛ࡞Ζ͏ - ֓ཁ • Ӻ͢ͺ͋ͱWebαʔϏεͱ͸ʁ • ϋϯζΦϯ 1.

    ΞϓϦςϯϓϨʔτΛಡΈࠐ΋͏ 2. ఆظ݊Λར༻ͨ͠ӡ௞ܭࢉΛ͠Α͏ 3. ୳ࡧ৚݅ઃఆϘλϯΛ௥Ճ͠Α͏ 4. ܦ࿏Λ࠶ݱ͢ΔػೳΛ௥Ճ͠Α͏
  2. Ӻ͢ͺ͋ͱWebαʔϏε Ӻσʔλɺܦ࿏ݕࡧͷWebAPI Ӻ͢ͺ͋ͱ͕࣋ͭػೳΛ WebAPIͱͯ͠ఏڙ ٕज़తͳϙΠϯτ • RESTfuʢ෩ʣ • Ϩεϙϯε͸XML or

    JSON • ϦϑΝϨϯε͸WebͰެ։ • αϯϓϧ͸GithubͰެ։ • ৐׵Ҋ಺αʔϏε • ཱྀඅަ௨අਫ਼ࢉγεςϜ ར༻γʔϯ બ΂Δ2ͭͷϓϥϯ • ແྉͰ࢖͑ΔϑϦʔϓϥϯ • શͯͷػೳ͕࢖͑Δελϯμʔυϓϥϯ
  3. Ӻ͢ͺ͋ͱWebαʔϏε Ӻσʔλɺܦ࿏ݕࡧͷWebAPI Ӻ͢ͺ͋ͱ͕࣋ͭػೳΛ WebAPIͱͯ͠ఏڙ ٕज़తͳϙΠϯτ • RESTfuʢ෩ʣ • Ϩεϙϯε͸XML or

    JSON • ϦϑΝϨϯε͸WebͰެ։ • αϯϓϧ͸GithubͰެ։ • ৐׵Ҋ಺αʔϏε • ௨ۈඅ؅ཧγεςϜ • ཱྀඅަ௨අਫ਼ࢉγεςϜ ར༻γʔϯ ࠓճͷϋϯζΦϯͰ͸ ελϯμʔυϓϥϯͷػೳΛར༻͠·͢ Ӻ͢ͺ͋ͱWebαʔϏεͷελϯμʔυϓϥϯ͸ 90೔ؒແྉͰ͓ࢼ͠Ͱ͖·͢ ͓ਃ͠ࠐΈ͸ͪ͜Βˣ https://ekiworld.net/trial/index.php?case=6
  4. 1. ࣗ෼ͷ؀ڥͰΞϓϦ͕ಈ͘ঢ়ଶʹ͠Α͏ ZIPϑΝΠϧͷμ΢ϯϩʔυ IBOETPO ᵓᴷᴷ ᴹᵓᴷᴷFLJTQFSUKT ᴹᵋᴷᴷަ௨අਃ੥ΞϓϦ[JQ ᵓᴷᴷ ᴹᵓᴷᴷFLJTQFSUKT ᴹᵋᴷᴷFYQ(VJ$POEJUJPO

    ᴹᵓᴷᴷFYQ$TT ᴹᴹᵋᴷᴷFYQ(VJ$POEJUJPODTT ᴹᵓᴷᴷFYQ(VJ$POEJUJPOKT ᴹᵋᴷᴷFYQ*NBHFT ᵋᴷᴷ ᵓᴷᴷFLJTQFSUKT ᵓᴷᴷFLJTQFSU%FUBJMKT ᵋᴷᴷަ௨අਃ੥ৄࡉΞϓϦ[JQ ;*1ϑΝΠϧͷத਎ͷ σΟϨΫτϦߏ੒Ͱ͢
  5. 1. ࣗ෼ͷ؀ڥͰΞϓϦ͕ಈ͘ঢ়ଶʹ͠Α͏ ZIPϑΝΠϧͷߏ੒ IBOETPO ᵓᴷᴷ ᴹᵓᴷᴷFLJTQFSUKT ᴹᵋᴷᴷަ௨අਃ੥ΞϓϦ[JQ ᵓᴷᴷ ᴹᵓᴷᴷFLJTQFSUKT ᴹᵋᴷᴷFYQ(VJ$POEJUJPO

    ᴹᵓᴷᴷFYQ$TT ᴹᴹᵋᴷᴷFYQ(VJ$POEJUJPODTT ᴹᵓᴷᴷFYQ(VJ$POEJUJPOKT ᴹᵋᴷᴷFYQ*NBHFT ᵋᴷᴷ ᵓᴷᴷFLJTQFSUKT ᵓᴷᴷFLJTQFSU%FUBJMKT ᵋᴷᴷަ௨අਃ੥ৄࡉΞϓϦ[JQ ࣍ͷ޻ఔͰ ʮަ௨අਃ੥ΞϓϦ[JQʯ Λར༻͠·͢
  6. JavaScriptϑΝΠϧͷฤू QBUIUPIBOETPOFLJTQFSUKTϑΝΠϧΛ ΤσΟλ౳Ͱ։͖·͢ (function($) { "use strict"; // Ӻ͢ͺ͋ͱWebαʔϏεͷΞΫηεΩʔ var

    ekispertAccessKey = ‘xxx..’; // ަ௨අਃ੥ৄࡉΞϓϦID var detailAppId = ''; ަ௨අਃ੥ৄࡉΞϓϦͷ ΞϓϦ*%Λೖྗ͠·͢ ϑΝΠϧΛอଘ 1. ࣗ෼ͷ؀ڥͰΞϓϦ͕ಈ͘ঢ়ଶʹ͠Α͏
  7. 2. ఆظ݊Λར༻ͨ͠ӡ௞ܭࢉΛ͠Α͏ APIͷ࢓༷ https://api.ekispert.jp/v1/json/search/course/extreme? key=xxx&viaList=22905:22884&date=20180720&searc hType=plain ϒϥ΢β͔Β ΞΫηεͯ͠ΈΑ͏ +40/σʔλͷϨεϙϯε͕ݟͮΒ͍ʁ LJOUPOFΞϓϦ಺Ͱ࣮ࡍʹୟ͍͍ͯΔͷ͸͖ͬ͞ͷ63-Ͱ͕͢

    9.-σʔλͷํ͕ݟ΍͍͔͢΋ͳͷͰ ͔͜͜Β͸9.-σʔλͰઆ໌͠·͢Ͷ ˞σʔλϑΥʔϚοτ͕ҟͳΔ͚ͩͰத਎͸ಉ͡Ͱ͢ https://api.ekispert.jp/v1/xml/search/course/extreme? key=xxx&viaList=22905:22884&date=20180720&search Type=plain
  8. 2. ఆظ݊Λར༻ͨ͠ӡ௞ܭࢉΛ͠Α͏ APIͷ࢓༷ https://api.ekispert.jp/v1/xml/search/course/extreme? key=xxx&viaList=22905:22884&date=20180720&searchType= plain ΫΤϦύϥϝʔλɿ σʔλϑΥʔϚοτɿ 9.-PS+40/͕ࢦఆͰ͖·͢ "1*ͷػೳɿ

    ަ௨අਫ਼ࢉΞϓϦͷཪଆͰ͸ Ӻ؆қ৘ใ"1* TUBUJPOMJHIU  ܦ࿏୳ࡧ"1* TFBSDIDPVSTFFYUSFNF ͳͲ͕ར༻͞Ε͍ͯ·͢ LFZ Ӻ͢ͺ͋ͱ8FCαʔϏεͷΞΫηεΩʔ WJB-JTU ग़ൃ஍ɺܦ༝஍ɺ౸ண஍ EBUF ୳ࡧ೔ʢ::::..%%ʣ TFBSDI5ZQF ୳ࡧछผ
  9. 2. ఆظ݊Λར༻ͨ͠ӡ௞ܭࢉΛ͠Α͏ APIͷ࢓༷ https://api.ekispert.jp/v1/xml/search/course/extreme? key=xxx&viaList=22905:22884&date=20180720
 &searchType=plain ग़ൃ஍ɺܦ༝஍ɺ౸ண஍ΛͦΕͧΕίϩϯʮʯͰ۠੾Γ·͢ɻ
 ʮʯ͸ീԦࢠӺͷӺίʔυɺʮʯ͸೔ຊڮ ౦ژ౎ ӺͷӺίʔυΛ


    ද͍ͯ͠·͢ɻWJB-JTUʹ͸ɺӺίʔυҎ֎ʹ΋ɺӺͷ໊শɺҢ౓ܦ౓ɺॅॴͳͲΛ
 ࢦఆ͢Δ͜ͱ͕Ͱ͖·͢ɻ Ӻ͢ͺ͋ͱ8FCαʔϏεͰ͸ɺμΠϠσʔλΛ࢖͏୳ࡧʢμΠϠʹΑΔ୳ࡧʣͱɺ
 ฏ೔೔தͷฏۉతͳॴཁ࣌ؒΛར༻ͨ͠୳ࡧʢฏۉ଴ͪ࣌ؒʹΑΔ୳ࡧʣͷ
 ೋͭͷ୳ࡧํ๏͕͋ΓɺͦΕΛ͞Βʹࡉ෼Խͨ͠΋ͷ͕୳ࡧछผͱͳΓ·͢ɻ
  10. 2. ఆظ݊Λར༻ͨ͠ӡ௞ܭࢉΛ͠Α͏ ఆظܦ࿏γϦΞϥΠζσʔλͷऔಘํ๏ https://api.ekispert.jp/v1/xml/search/course/extreme? key=xxx&viaList=22723:22741:22671&searchType=plain Ӻ৘ใ"1* TUBUJPO ΍Ӻ؆қ৘ใ"1* TUBUJPOMJHIU Ͱ

    Ӻίʔυ͕औಘͰ͖·͢ ఆظܦ࿏γϦΞϥΠζσʔλ͸ɺܦ࿏୳ࡧAPIͷϨεϙϯεʹ෇༩͞ΕΔͷͰ ܦ࿏୳ࡧAPIͰ௨ۈఆظ݊ͷܦ࿏Λݕࡧ͠·͢ ྫ͑͹ɺԼ๺୔ʔ৽॓ʔߴԁࣉͷ௨ۈఆظ݊Λ͍࣋ͬͯΔͱͨ͠Βɺ ҎԼͷϦΫΤετʹͳΓ·͢
  11. 2. ఆظ݊Λར༻ͨ͠ӡ௞ܭࢉΛ͠Α͏ ఆظܦ࿏γϦΞϥΠζσʔλͷऔಘํ๏ https://api.ekispert.jp/v1/xml/search/course/extreme? key=ajawaANhL9RWERyT&viaList=22723:22741:22671&searchT ype=plain Ӻ৘ใ"1* TUBUJPO ΍Ӻ؆қ৘ใ"1* TUBUJPOMJHIU

    Ͱ Ӻίʔυ͕औಘͰ͖·͢ ఆظܦ࿏γϦΞϥΠζσʔλ͸ɺܦ࿏୳ࡧAPIͷϨεϙϯεʹ෇༩͞ΕΔͷͰ ܦ࿏୳ࡧAPIͰ௨ۈఆظ݊ͷܦ࿏Λݕࡧ͠·͢ ྫ͑͹ɺԼ๺୔ʔ৽॓ʔߴԁࣉͷ௨ۈఆظ݊Λ͍࣋ͬͯΔͱͨ͠Βɺ ҎԼͷϦΫΤετʹͳΓ·͢ ʮԼ๺୔খాٸখాݪઢ৽̧̟॓தԝઢշ଎ߴԁࣉʯ ͷɺఆظܦ࿏γϦΞϥΠζσʔλΛ ༻ҙ͓͖ͯ͠·ͨ͠ 7L72B&$QG)"2&%QH&[&&L&#Q7K%X2(M8/ 9#"B7:KX84XX&#"6#/24M8/9&"2&$"20LC2 4M8*)LT6#Q7K%"R7:2."#""'".6#Q7K7"R7: KX.##"&'""H#$H& EBBFFDE FFGDDF
  12. ZIPϑΝΠϧͷߏ੒ IBOETPO ᵓᴷᴷ ᴹᵓᴷᴷFLJTQFSUKT ᴹᵋᴷᴷަ௨අਃ੥ΞϓϦ[JQ ᵓᴷᴷ ᴹᵓᴷᴷFLJTQFSUKT ᴹᵋᴷᴷFYQ(VJ$POEJUJPO ᴹᵓᴷᴷFYQ$TT ᴹᴹᵋᴷᴷFYQ(VJ$POEJUJPODTT

    ᴹᵓᴷᴷFYQ(VJ$POEJUJPOKT ᴹᵋᴷᴷFYQ*NBHFT ᵋᴷᴷ ᵓᴷᴷFLJTQFSUKT ᵓᴷᴷFLJTQFSU%FUBJMKT ᵋᴷᴷަ௨අਃ੥ৄࡉΞϓϦ[JQ ࣍ͷ޻ఔͰ ʮFLJTQFSUKTʯͱ ʮFYQ(VJ$POEJUJPOʯσΟϨΫτϦ Λར༻͠·͢ 3. ୳ࡧ৚݅ઃఆϘλϯΛ௥Ճ͠Α͏
  13. ิ଍ IBOETPO ᵓᴷᴷ ᴹᵓᴷᴷFLJTQFSUKT ᴹᵋᴷᴷަ௨අਃ੥ΞϓϦ[JQ ᵓᴷᴷ ᴹᵓᴷᴷFLJTQFSUKT ᴹᵋᴷᴷFYQ(VJ$POEJUJPO ᴹᵓᴷᴷFYQ$TT ᴹᴹᵋᴷᴷFYQ(VJ$POEJUJPODTT

    ᴹᵓᴷᴷFYQ(VJ$POEJUJPOKT ᴹᵋᴷᴷFYQ*NBHFT ᵋᴷᴷ ᵓᴷᴷFLJTQFSUKT ᵓᴷᴷFLJTQFSU%FUBJMKT ᵋᴷᴷަ௨අਃ੥ৄࡉΞϓϦ[JQ ͜ͷϑΝΠϧ܈͸ҰମԿʁ 3. ୳ࡧ৚݅ઃఆϘλϯΛ௥Ճ͠Α͏
  14. ZIPϑΝΠϧͷߏ੒ IBOETPO ᵓᴷᴷ ᴹᵓᴷᴷFLJTQFSUKT ᴹᵋᴷᴷަ௨අਃ੥ΞϓϦ[JQ ᵓᴷᴷ ᴹᵓᴷᴷFLJTQFSUKT ᴹᵋᴷᴷFYQ(VJ$POEJUJPO ᴹᵓᴷᴷFYQ$TT ᴹᴹᵋᴷᴷFYQ(VJ$POEJUJPODTT

    ᴹᵓᴷᴷFYQ(VJ$POEJUJPOKT ᴹᵋᴷᴷFYQ*NBHFT ᵋᴷᴷ ᵓᴷᴷFLJTQFSU%FUBJMKT ᵓᴷᴷFLJTQFSUKT ᵋᴷᴷަ௨අਃ੥ৄࡉΞϓϦ[JQ ࣍ͷ޻ఔͰ ʮFLJTQFSUKTʯͱ ʮަ௨අਃ੥ৄࡉΞϓϦ[JQʯ Λར༻͠·͢ 4. ܦ࿏Λ࠶ݱ͢ΔػೳΛ௥Ճ͠Α͏
  15. 4. ܦ࿏Λ࠶ݱ͢ΔػೳΛ௥Ճ͠Α͏ JavaScriptϑΝΠϧͷฤू QBUIUPIBOETPOFLJTQFSUKTϑΝΠϧΛ ΤσΟλ౳Ͱ։͖·͢ (function($) { "use strict"; //

    Ӻ͢ͺ͋ͱWebαʔϏεͷΞΫηεΩʔ var ekispertAccessKey = ‘xxx..’; // ަ௨අਃ੥ৄࡉΞϓϦID var detailAppId = ''; ަ௨අਃ੥ৄࡉΞϓϦͷ ΞϓϦ*%Λೖྗ͠·͢ ϑΝΠϧΛอଘ
  16. 4. ܦ࿏Λ࠶ݱ͢ΔػೳΛ௥Ճ͠Α͏ ิ଍ ܦ࿏Λ࠶ݱͤ͞ΔͨΊʹɺ ܦ࿏୳ࡧ"1* TFBSDIDPVSTFFYUSFNF ͷ Ϩεϙϯεͷ+40/σʔλΛอଘ͢Δඞཁ͕͋Γ·͢ɻ ܦ࿏Λ࠶ݱͰ͖Δʮܦ࿏ͷ࠶ݱʗఆظ݊ɾࢦఆྻंར༻"1* DPVSTFFEJU

    ʯͰ͸ɺ ͋͘·Ͱ΋Ұ࣌తͳ࠶ݱΛ૝ఆͯ͠࡞ΒΕ͍ͯ·͢ɻ ࠓճͷΑ͏ʹɺঝೝऀ͕ܦ࿏Λ֬ೝ͢ΔΑ͏ͳ৔໘Ͱ͸ +40/σʔλΛؙʑอଘ͢Δํ๏͕࣮֬ʹܦ࿏Λ࠶ݱ͢Δ͜ͱ͕Ͱ͖·͢ɻ ˞μΠϠ৘ใΛอ࣋͢Δߦҝ͸Ӻ͢ͺ͋ͱ8FCαʔϏεͷن໿ʹҧ൓͠·͢ͷͰɺ μΠϠʹΑΔ୳ࡧͰͷܦ࿏୳ࡧ݁Ռ͸อ࣋͢Δ͜ͱ͸Ͱ͖·ͤΜɻ ͝஫ҙ͍ͩ͘͞ɻ