Giter Site home page Giter Site logo

line-bot-imgur-tutorial's Introduction

line-bot-imgur-tutorial

透過 imgur api 製作簡單 line bot

教學

詳細 line bot 教學,請參考之前寫的 line-bot-tutorial

特色

  • 傳任意圖片給 line bot 機器人,機器人將自動幫你把圖片上傳到 imgur ( imgur 相簿可以事先定義好 )。
  • 從大家上傳的圖片中任意回傳一張圖片給使用者。

imgur api 說明

請到下方獲取自己的 CLIENT_ID , CLIENT_SECRET

alt tag

album_id 直接從相簿網址的最後看就可以看到了。

config.py 裡面為自己的 imgur 的 key

請記得將下方修改為自己的

# imgur key
client_id = 'YOUR_IMGUR_CLIENT_ID'
client_secret = 'YOUR_IMGUR__CLIENT_SECRET'
album_id = 'YOUR_IMGUR_ALBUM_ID'
access_token = 'YOUR_IMGUR_ACCESS_TOKEN'
refresh_token = 'YOUR_IMGUR_ACCESS_TOKEN'

# line bot key
line_channel_access_token = 'YOUR_CHANNEL_ACCESS_TOKEN'
line_channel_secret = 'YOUR_CHANNEL_SECRET'

auth.py 這支程式為取得 token ( access_token 以及 refresh_token ), 第一次執行時,需要請你輸入 pincode ,如下圖

alt tag

upload_imgur_demo_1.py 為測試 imgurpython 上傳 api 簡單範例。

upload_imgur_demo_2.py 為取得token ( access_token 以及 refresh_token ) 之後, 透過下方 api 上傳圖片到自己指定的相簿。

( 透過 access_token 以及 refresh_token 可以不用再輸入 pincode )

client = ImgurClient(client_id, client_secret, access_token, refresh_token)

詳細範例可參考 imgurpython,上傳範例為官方範例簡單修改。

執行畫面

請先加入好友

我的 QRCODE

alt tag

或是手機直接點選 https://line.me/R/ti/p/%40gmy1077x

功能

alt tag

alt tag

alt tag

執行環境

  • Python 3.9

Reference

Donation

文章都是我自己研究內化後原創,如果有幫助到您,也想鼓勵我的話,歡迎請我喝一杯咖啡:laughing:

alt tag

贊助者付款

License

MIT license

line-bot-imgur-tutorial's People

Contributors

twtrubiks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.