$30 off During Our Annual Pro Sale. View Details »

企業システムにおけるTwitter API適用事例とTwitter4Jアップデート #TwitterDevJP

yusuke
September 17, 2022

企業システムにおけるTwitter API適用事例とTwitter4Jアップデート #TwitterDevJP

yusuke

September 17, 2022
Tweet

More Decks by yusuke

Other Decks in Technology

Transcript

  1. اۀγεςϜʹ͓͚Δ Twitter APIద༻ࣄྫ @yusuke ࢁຊϢʔεέ ͱTwitter4JΞοϓσʔτ

  2. w+BWB޷͖ͷ044σϕϩού w+BWBνϟϯϐΦϯ w5XJUUFS+࡞ऀ ޷͖ͳϒΩγϟʔϓϚʔΧʔ ϑϨϯυίʔυ48

  3. 5IFUJNFMJOF w ೥݄5XJUUFSɺ5XJUUFS"1*Λൃݟ w ೥݄5XJUUFS+ΛϦϦʔε w ೥"1*͕޷͖͗ͯ͢5XJUUFSʹೖࣾ %FWFMPQFS"EWPDBUFͱͯ͠ ࠃ಺σϕϩούͷࢧԉɺ%FWFMPQFS5FBUJNFͷ։࠵౳ w

    ೥ʙגࣜձࣾαϜϥΠζϜઃཱ
  4. ྑ͋͘Δ5XJUUFS"1*ͷࣄྫ wΩϟϯϖʔϯ wήʔϜͰ࣮੷ΛπΠʔτ wট଴ w4/4ΞΧ΢ϯτϩάΠϯ ίϯγϡʔϚ޲͚ͷద༻͕ଟ͍

  5. גࣜձࣾαϜϥΠζϜ ւ֎ͷπʔϧɺαʔϏεൢച +FU#SBJOTɺ(JU)VCɺ%BUBEPH౳ ࣗࣾ੡඼։ൃɾൢച !$*DMPOF

  6. wࣾ௕ɺӦۀɺٕज़αϙʔτ໊ͷྵࡉاۀ wൢ؅γεςϜɺ&$γεςϜ౳͸಺੡ w๏ਓސ٬໿ઍɺݸਓސ٬໿ສ גࣜձࣾαϜϥΠζϜ ۀ຿ޮ཰ԽͷҰ؀ͱͯ͠Twitter APIΛར༻

  7. גࣜձࣾαϜϥΠζϜγεςϜߏ੒ &$ ൢച؅ཧ ࢮ׆౳؂ࢹ ग़ୀࣾ௨஌

  8. Ӧۀ࣌ؒ֎ɺॕٳ೔ʹ5XJUUFS%.Ͱ௨஌ &$ උߟཝʹ໰͍߹Θ͕ͤهࡌ ܾࡁ࣌ɺΧʔυ໊ٛ૬ҧ౳ ॕٳ೔ɾӦۀ࣌ؒ൑ఆIUUQTHJUIVCDPNZVTVLFCVTJOFTT$BMFOEBS+ ൢച؅ཧ ফ͠ࠐΈ࣌ɺֹۚෆҰக౳

  9. ࢮ׆౳؂ࢹ αʔόμ΢ϯ Ϩεϙϯε஗Ԇ αʔόূ໌ॻ༗ޮظݶ 5XJUUFS%.Ͱ௨஌

  10. ग़ࣾୀࣾͰπΠʔτ ग़ୀࣾ௨஌ ग़ୀࣾঢ়گΛπΠʔτ

  11. اۀͷ5XJUUFS"1*ར༻ wӦۀ࣌ؒ֎ॕٳ೔౳ʹ௨஌ wγεςϜͷΠϕϯτ wࣗಈԽͰग़དྷͳ͍ঝೝϫʔΫϑϩʔ wϚʔέςΟϯά w8FCαΠτ63-ɺϋογϡλάɺ঎඼໊Τΰα w$3. w%.ɺ!πΠʔτͰސ٬ରԠ

  12. 5XJUUFS࿈ܞ͢ΔϝϦοτ ʮ͍ͭ΋ݟ͍ͯΔπʔϧʯΛ࢖͑Δ Ϟχλεɺʮར༻࣮ଶௐࠪϏδωενϟοτπʔϧฤʯΛൃදIUUQTNPOJUBTDPKQDIBU@UPPM

  13. 5XJUUFS࿈ܞ͢ΔϝϦοτ wը໘Λ࡞੒͢Δඞཁ͕ͳ͍ w૒ํ޲ͷ΍ΓͱΓ΋؆୯ wϫϯλονͰΠϯλϥΫτՄೳ 2VJDLSFTQPOTFˠ

  14. None
  15. Ͳͷ"1*Λ࢖͏΂͖͔ w"1*W "1*W  w6TFS4USFBNTͷ୅ସ͸ʁ

  16. WΛ࢖͏ϝϦοτ wWʹ͔͠Ͱ͖ͳ͍͜ͱ wεϖʔεɺϒοΫϚʔΫ΁ͷΞΫηε౳

  17. ৽نʹAPIΛѻ͏ͳΒv2͕ѹ౗తʹ෼͔Γ΍͍͢ WΛ࢖͏ϝϦοτ w࣮ࡍͷ6*༻ޠͱ"1*༻ޠ͕౷Ұ͞Ε͍ͯΔ ྫ  w"1*WGPMMPXFSGSJFOE w"1*WGPMMPXFSGPMMPXJOH

  18. WΛ࢖͏ϝϦοτ w"1*ઃܭ͕ϞμϯྫϑΥϩʔΛ֎͢ w7 %&-&5&VTFST\TPVSDF@VTFS@JE^GPMMPXJOH\UBSHFU@VTFS@JE^ w7 1045GSJFOETIJQTEFTUSPZKTPO VTFS@JE\VTFS@JE^

  19. "1*WͰ͸ग़དྷͳ͍͜ͱ΋͋Δ wྫμΠϨΫτϝοηʔδૹड৴ IUUQTUSFMMPDPNCNZGS,X7UXJUUFSEFWFMPQFSQMBUGPSNSPBENBQ

  20. "1*WʁWʁ w"1*WͰग़དྷΔ͜ͱ͸"1*WͰ wطଘΞϓϦ͸ٸ͍ͰҠߦ͢Δඞཁ͸ͳͦ͞͏

  21. ΈΜͳେ޷͖6TFS4USFBNTͷ୅ସ͸ʁ w"DDPVOU"DUJWJUZ"1* w8FCIPPLͰϑΥϩʔɺ%.౳ͷ௨஌Λड৴ w࠶઀ଓॲཧෆཁ IUUQTEFWFMPQFSUXJUUFSDPNKBEPDTUVUPSJBMTHFUUJOHTUBSUFEXJUIUIFBDDPVOUBDUJWJUZBQJ

  22. ΈΜͳେ޷͖6TFS4USFBNTͷ୅ସ͸ʁ w"DDPVOU"DUJWJUZ"1* w8FCIPPLͰϑΥϩʔɺ%.౳ͷ௨஌Λड৴ w࠶઀ଓॲཧෆཁ IUUQTEFWFMPQFSUXJUUFSDPNKBEPDTUVUPSJBMTHFUUJOHTUBSUFEXJUIUIFBDDPVOUBDUJWJUZBQJ ΫϥΠΞϯτΞϓϦ։ൃʹ͸ෆ޲͖

  23. 5XJUUFS+ϩʔυϚοϓ wཁ+BWB  w"1*Wαϙʔτ wϞμϯͳΠϯλʔϑΣʔε wϞδϡʔϧαϙʔτ w!/VMMBCMF!/PU/VMM!3BOHFΞϊςʔτ w"DDPVOU"DUJWJUZ"1*αϙʔτ

  24. ϞμϯͳΠϯλʔϑΣʔε Twitter twitter = new TwitterFactory(new ConfigurationBuilder() .setOAuthConsumerKey("my consumer key")

    .setOAuthConsumerSecret("my consumer secret") .build()).getInstance(); Twitter twitter = Twitter.newBuilder() .oAuthConsumerKey("my consumer key") .oAuthConsumerSecret("my consumer secret") .build();
  25. Ϟδϡʔϧαϙʔτ

  26. !/VMMBCMF!/PU/VMM!3BOHFΞϊςʔτ ݱߦ 3BOHFΞϊςʔτ෇͖

  27. "DDPVOU"DUJWJUZ"1*αϙʔτ var activity = TwitterAccountActivity.newBuilder() .onDirectMessageReceived(dm -> System.out.printf("direct message received:%s"

    , dm.getText())) .onMention(tweet -> System.out.printf("mention received:%s" , tweet.getText())) .onPort(8080).build(); activity.start(); activity.await();
  28. 3&45"1* ΠϕϯτυϦϒϯ var restActivity = TwitterRestBasedAccountActivity .newBuilder() .onDirectMessageReceived(dm -> System.out.printf("direct

    message received:%s" , dm.getText())) .onMention(tweet -> System.out.printf("direct message received:%s" , tweet.getText())) .pollIntervalSeconds(60).build(); restActivity.start(); restActivity.await();
  29. IUUQTHJUIVCDPN5XJUUFS+5XJUUFS+

  30. ਐԽ͢Δ5XJUUFS ਐԽ͢Δ5XJUUFS"1* "1*Λ׆༻ͯ͠ҰॹʹਐԽ͠·͠ΐ͏ʂ

  31. اۀγεςϜʹ͓͚Δ Twitter APIద༻ࣄྫ @yusuke ࢁຊϢʔεέ ͱTwitter4JΞοϓσʔτ