講者: 土豆
日期: 2020/05/17
而且它真的五告岔
講者很自豪地說,他寫了一個麥當勞報報自動抽籤機器人
有些東西,還是自己玩玩就好了...
應該想過一個問題
這個資料是誰給它的?
Request
Response
JSON
API
System API: OS <-> Program
Python的sys套件: OS <-> Python
Facebook的API: Facebook <-> Program
政府開放資料API: 政府網站 <-> Program
應用程式之間可程式化的溝通介面
Application Programming Interface
Web API
This 15 wheel: Airtable <-> Wheel
URL
System API
Library
Request: 我要抽籤!
Response
JSON
API
URL??
URL!!
import requests
import json
from datetime import datetime
from linebot import LineBotApi
from linebot.models import TextSendMessage, ImageSendMessage
line_bot_api = LineBotApi('Your Channel access token')
data = {
"access_token": "Your App access token",
"source_info": {
"app_version": "2.2.4",
"device_time": datetime.now().strftime("%Y/%m/%d %H:%M:%S"),
"device_uuid": "Your device uuid",
"model_id": "G8232",
"os_version": "8.0.0",
"platform": "Android"
}
}
r = requests.post('https://api1.mcddailyapp.com/lottery/get_item', data=json.dumps(data))
res = r.json()
replymsg = res['rm']
if 'sticker' in res['results']:
replyimg = res['results']['sticker']['object_info']['image']['url']
elif 'coupon' in res['results']:
replyimg = res['results']['coupon']['object_info']['image']['url']
else:
replyimg = 'unkown'
line_bot_api.push_message('Your Line ID', TextSendMessage(text=replymsg))
line_bot_api.push_message('Your Line ID', ImageSendMessage(original_content_url=replyimg, preview_image_url=replyimg))
Heroku Add-on: Heroku Scheduler
定期執行特定指令
免費服務,但是要先綁定信用卡
這東西你找不到參考資料的拉
好啦,勉強放一些