コード例 #1
0
 def setUp(self):
     self.tested = NaverTalkApi('test_naver_talk_access_token')
コード例 #2
0
ファイル: example.py プロジェクト: Soo92/ALINE_GIT
#-*- encoding:utf-8 -*-
"""
    Example code for nta
    See how it works: https://talk.naver.com/ct/wc4qdz
"""
import os
from flask import Flask, request

from nta import NaverTalkApi, Template, Button
from nta import NaverTalkApiError, NaverTalkPaymentError, NaverTalkApiConnectionError

app = Flask(__name__)
ntalk = NaverTalkApi('/1pVqCZARvWp5ThJ0K6D')


@app.route('/', methods=['POST'])
def app_enterance():
    print("*" * 40)
    req = request.get_data(as_text=True)
    print('* Recieved Data:')
    print(req)
    try:
        ntalk.webhook_handler(req)
    except NaverTalkApiError as e:
        print(e)
    except NaverTalkApiConnectionError as e:
        print(e)
    except NaverTalkPaymentError as e:
        return 400

    print("*" * 40)
コード例 #3
0
#-*- encoding:utf-8 -*-
"""
     In Persistent Menu,
     Option Button is not allowed.
     Sad..

     How to register persistent menu:
     python persistent_menu_example.py

"""
import os

from nta import NaverTalkApi, Button

NAVER_TALK_ACCESS_TOKEN = os.environ['naver_talk_access_token']
ntalk = NaverTalkApi(NAVER_TALK_ACCESS_TOKEN)


def my_callback(res, payload):
    #callback function for showing result of send persistent menu payload
    print(res)


ntalk.persistent_menu(menus=[
    Button.ButtonText('고정 메뉴 테스트', 'PersistentMenu'),
    Button.ButtonLink('Link to NTA',
                      'https://github.com/HwangWonYo/naver_talk_sdk'),
    Button.ButtonNested(title='버튼을 품은 버튼 이라는데?',
                        menus=[
                            Button.ButtonText('아무 의미 없는 버튼'),
                            Button.ButtonText('카드뷰 보기', 'CardView'),