Exemplo n.º 1
0
def main():
    liff_api = LIFF("8QntITqnfdIc7sU4kBPskoZhOBEFvl3I9a/4OSMraNubY/h3ZwcFY5aDd2O16RPIRWK1f5oY0Aew5LJL91mlnjkP9Ugq6j4c0ZmJp2hWTkGnHUodLdvVcSJj+tCzzH9iyfBrDJ8NMtGln0MwZGWmjAdB04t89/1O/w1cDnyilFU=")

    try:
        # If you want to add LIFF app
        liff_id = liff_api.add(
            view_type="compact",
            view_url="https://https://liff-for-hjuav.herokuapp.com/hotel_form.html")
            # 400 Error or 401 Error
        try:
            # If you want to update LIFF app
            liff_api.update(liff_id, 
            view_type="full",
            view_url="https://https://liff-for-hjuav.herokuapp.com/hotel_form.html")
        except ErrorResponse as err:
            # 401 Error or 404 Error
            print(err.message)
            return 
    except ErrorResponse as err:
        # 401 Error or 404 Error
        print(err.message)
        return 

    try:
        # If you want to get all LIFF apps
        apps_info = liff_api.get()
        for app_info in apps_info:
            try:
                # If you want to delete LIFF app
                liff_api.delete(app_info["liffId"])
            except ErrorResponse as err:
                # 401 Error or 404 Error
                print(err.message)
                return 
    except ErrorResponse as err:
        # 401 Error or 404 Error
        print(err.message)
        return 
Exemplo n.º 2
0
from liffpy import LineFrontendFramework as LIFF

liff = LIFF('4/CIQ3/kPw12albwqmprAzy/LZPNJWP6jA2a4HJvEJfn126d3xVEpqV57xnenOUxMqw11ndAxZ5wlO0lEXoF/stW7SISBOpgSfRJ17lERPWm11iaof+EyF+30m3hl0K0YBnTre85z9/xQ45yF+G+JgdB04t89/1O/w1cDnyilFU=')

#liff.add(view_type="tall",view_url='https://www.google.com.tw/webhp?tab=rw')
# url = 'https://liff.line.me/' + liff.add(view_type="tall",view_url='https://e9734a766c0a.ap.ngrok.io/detail/Ub52d90a6b2c9b05bed228af9d7538a6b/1603157435')
print(liff.get())
# print(url)
print(len(liff.get()))
#print(liff.get()[0]['liffId'])

try:
    if len(liff.get()) >= 1:
        for i in range(len(liff.get())):
            print(liff.get()[i]['liffId'])
            #liff.delete(liff.get()[i]['liffId'])
except:
    pass
Exemplo n.º 3
0
                            FlexSendMessage, VideoSendMessage,
                            StickerSendMessage, AudioSendMessage)
from linebot.models.template import (ButtonsTemplate, CarouselTemplate,
                                     ConfirmTemplate, ImageCarouselTemplate)
from linebot.models.template import *
from linebot.models import PostbackEvent
from linebot.models import (QuickReply, QuickReplyButton, MessageAction)

import re
import requests
import pyimgur
import subprocess
import json

# ============ 需到FoodLine/settings.py 新增 line相關key =================
liff_api = LIFF(settings.LINE_CHANNEL_ACCESS_TOKEN)
line_bot_api = LineBotApi(settings.LINE_CHANNEL_ACCESS_TOKEN)
handler = WebhookHandler(settings.LINE_CHANNEL_SECRET)


# ============ 用戶關注 =================
@handler.add(FollowEvent)
def handle_follow(event):
    uid = event.source.user_id
    profile = line_bot_api.get_profile(uid)
    name = profile.display_name
    pic_url = profile.picture_url

    if User_Info.objects.filter(uid=uid).exists() == False:

        User_Info.objects.create(uid=uid, name=name, pic_url=pic_url)
Exemplo n.º 4
0
)

# 載入基礎設定檔
secretFileContentJson=json.load(open("./line_secret_key",'r',encoding='utf8'))
server_url=secretFileContentJson.get("server_url")

# 設定Server啟用細節
app = Flask(__name__,static_url_path = "/素材" , static_folder = "./素材/")

# 生成實體物件
line_bot_api = LineBotApi(secretFileContentJson.get("channel_access_token"))
handler = WebhookHandler(secretFileContentJson.get("secret_key"))

# liff
line_bot_token = secretFileContentJson.get("channel_access_token")
liff = LIFF(line_bot_token)

# 啟動server對外接口,使Line能丟消息進來
@app.route("/", methods=['POST'])
def callback():
    # get X-Line-Signature header value
    signature = request.headers['X-Line-Signature']

    # get request body as text
    body = request.get_data(as_text=True)
    app.logger.info("Request body: " + body)

    # handle webhook body
    try:
        handler.handle(body, signature)
    except InvalidSignatureError:
Exemplo n.º 5
0
#將m4a語音專程wav語音時專用
from pydub import AudioSegment
import soundfile

global beacon_id
beacon_id = 0

# 註冊googlemap的API的client
gmaps = googlemaps.Client(key='GOOGLE_MAP_API_KEY')

app = Flask(__name__)

line_bot_api = LineBotApi('CHANNEL_ACCESS_TOKEN')
handler = WebhookHandler('LINE_CHANNEL_SECRET')
liff_api = LIFF('CHANNEL_ACCESS_TOKEN')

static_tmp_path = os.path.join(os.path.dirname(__file__), 'static', 'tmp')
Yilan_list = ['羅東','礁溪','宜蘭']

#創造一個tmp的路徑來下載圖片或者語音#
def make_static_tmp_dir():
    try:
        os.makedirs(static_tmp_path)
    except OSError as exc:
        if exc.errno == errno.EEXIST and os.path.isdir(static_tmp_path):
            pass
        else:
            raise

#****m4a轉wav 16 bits****#