import requests
import sqlite3
import simplejson as json
from datetime import datetime, timedelta
import pandas as pd

#id_pw를 가져와서 리스트로 변환
con = sqlite3.connect('C:/Users/B180093/database/tcs.db')
user = pd.read_sql("SELECT * FROM id_pw", con)
user_info = user.values.tolist()
con.close()
id_pw = {'os_username': user_info[0][0], 'os_password': user_info[0][1]}

url = 'https://apis.worksmobile.com/r/kr1llsnPeSqSR/message/v1/bot/1809717/message/push'
headers = {
    'Content-Type' : 'application/json; charset=UTF-8',
    'consumerKey' : 'IuAF6mCrW4FiTxWF6bmm',
    'Authorization': 'Bearer AAABAXONcN0Ch9T4YmhyDiRG+1ilvRZoM1MoutdUZLzV6++m3h+/fipKAlD0I1OKCbAJFWhuiQV07ldyuY1M3qu0pVEKqWcrhPdK5k2PKp2Xo42bfFsPleMt8D0+ZHqJVGrXPdw3JheNM5hkVqpzEc0l24vlpymIeLTg74+aEUFa+SpI6mjkbP5vJwD5kR8auewDnQgmuE1cwdBVlveJq2ZDC7ohbAF29Hfd/Wmc75h72LAC3W1Zea+4LF/UpKoBnSxCmqSInyWmyYwAJ5HBrPp/9PdoxB5SqRma2aFswhmwvaR/6AClqjmuAKdGlcgA+DertSmLCCer7i2iNXxNimgqXsrvEAHQQpLwtrv8IGdcV/sf'
}


payload = {
        "accountId": "bluenote212@telechips.com",
        "content": {
                    "type": "carousel",
                    "columns": [
                                    {
                                        "title": "content1",
                                        "text": "content1",
                                        "actions": [
                                                    {
                                                      "type": "message",
                                                      "label": "정적분석",
                                                      "text": "Yes",
                                                      "postback": "static_analysis"
                                                    },
                                                    {
                                                        "type":"uri",
                                                        "label":"qac",
                                                        "uri":"https://www.naver.com"
                                                    }
                                                ]
                                    },
                                    {
                                        "title": "content2",
                                        "text": "content2",
                                        "actions": [
                                                    {
                                                        "type":"uri",
                                                        "label":"Talk",
                                                        "uri":"https://www.naver.com"
                                                    }
                                                ]
                                    }
                                ]
                  }
        }
r = requests.post(url, data=json.dumps(payload), headers=headers)
print(r, r.text)


