From 86ce350e5aadd610c239ec1b94bc7455df9218e8 Mon Sep 17 00:00:00 2001 From: Moe Date: Wed, 22 Aug 2018 20:28:26 +0700 Subject: [PATCH] Initial Release --- LiffRegister.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 LiffRegister.py diff --git a/LiffRegister.py b/LiffRegister.py new file mode 100644 index 0000000..fc97e8e --- /dev/null +++ b/LiffRegister.py @@ -0,0 +1,38 @@ +import requests, json + +# Input Data +clientid = input("Client ID : ") +channelsecret = input("Channel Secret : ") +type = input("Type (full/compact/tall): ") +url = input("URL (SSL): ") + +#Phase 1 (Get AuthToken) +host = "https://api.line.me/v2/oauth/accessToken" +headers = { + "Content-Type": "application/x-www-form-urlencoded" + } +data = { + "grant_type": "client_credentials", + "client_id": clientid, + "client_secret": channelsecret + } +req = requests.post(host, data=data, headers=headers) +result = json.loads(req.text) +authToken = result["access_token"] + +#Phase2 (Register Liff App) +host = "https://api.line.me/liff/v1/apps" +headers = { + "Authorization": "Bearer " + authToken, + "Content-Type": "application/json" +} +data = { + "view": { + "type": type, + "url": url + } +} +req = requests.post(host, json=data, headers=headers) +result = json.loads(req.text) +liffid = result["liffId"] +print ("Your Liff App : line://app/" + liffid)