Пример #1
0
def Ardread():
    count = 0
    while (True):
        if ARD.readable():
            NUM = ARD.readline()
            dist = Decode(NUM)
            print(dist)
            if dist <= 5:
                if count >= 3:
                    if __name__ == '__main__':
                        data = {
                            'message': {
                                'to': '01066896321',
                                'from': '01042149072',
                                'text': '쓰레기 가득참'
                            }
                        }
                        res = requests.post(config.getUrl('/messages/v4/send'),
                                            headers=auth.get_headers(
                                                config.apiKey,
                                                config.apiSecret),
                                            json=data)
                    count = 0
                else:
                    count = count + 1

            else:
                print("Not Full")
        else:
            print("FAIL")
Пример #2
0
import requests
import json
import configparser
import sys
import os.path

libdir = os.path.dirname(__file__)
sys.path.append(os.path.split(libdir)[0])

from auth import auth

config = configparser.ConfigParser()
config.read('config.ini')
apiKey = config['AUTH']['ApiKey']
apiSecret = config['AUTH']['ApiSecret']

if __name__ == '__main__':
    # [IMAGE_ID] 에 이미지 아이디를 넣어주세요
    res = requests.get(config['SERVER']['IMGURI'] + '/images/[IMAGE_ID]',
                       headers=auth.get_headers(apiKey, apiSecret))
    print(json.dumps(json.loads(res.text), indent=2, ensure_ascii=False))
import sys
import os.path
import image

sys.path.append('../')

from auth import auth
import config

if __name__ == '__main__':
    # 이미지를 바꾸시려면 testImage.jpg 대신
    # 사용하실 이미지가 있는 파일 경로를 넣어주세요
    imageInfo = json.loads(
        image.createImage('./testImage.jpg',
                          config.getUrl('/storage/v1/files'),
                          auth.get_headers(config.apiKey,
                                           config.apiSecret)).text)
    print(imageInfo)
    data = {
        'message': {
            'to': '수신번호 입력',
            'from': '발신번호 입력',
            'text': '발송 예제',
            'imageId': imageInfo['fileId']
        }
    }
    res = requests.post(config.getUrl('/messages/v4/send'),
                        headers=auth.get_headers(config.apiKey,
                                                 config.apiSecret),
                        json=data)
    print(json.dumps(json.loads(res.text), indent=2, ensure_ascii=False))
import image

libdir = os.path.dirname(__file__)
sys.path.append(os.path.split(libdir)[0])

from auth import auth

config = configparser.ConfigParser()
config.read('config.ini')
apiKey = config['AUTH']['ApiKey']
apiSecret = config['AUTH']['ApiSecret']

if __name__ == '__main__':
    # 이미지를 바꾸시려면 testImage.jpg 대신
    # 사용하실 이미지가 있는 파일 경로를 넣어주세요
    imageInfo = json.loads(
        image.createImage('./image/testImage.jpg', config['SERVER']['IMGURI'],
                          auth.get_headers(apiKey, apiSecret)).text)
    data = {
        'message': {
            'to': config['VALUE']['to'],
            'from': config['VALUE']['from'],
            'text': 'test',
            'imageId': imageInfo['imageId']
        }
    }
    res = requests.post(config['SERVER']['URI'] + 'send',
                        headers=auth.get_headers(apiKey, apiSecret),
                        json=data)
    print(json.dumps(json.loads(res.text), indent=2, ensure_ascii=False))
Пример #5
0
import json
import sys
import os.path
import image

sys.path.append('../')

from auth import auth
import config

if __name__ == '__main__':
    # 이미지를 바꾸시려면 testImage.jpg 대신
    # 사용하실 이미지가 있는 파일 경로를 넣어주세요
    res = image.createImage('./testImage.jpg', config.getUrl('/storage/v1/files'), auth.get_headers(config.apiKey, config.apiSecret))
    print(json.dumps(json.loads(res.text), indent=2, ensure_ascii=False))
Пример #6
0
# -*- coding: utf-8 -*-
import requests
import json
import sys
import os.path

sys.path.append('../')

from auth import auth
import config


if __name__ == '__main__':
    data = {
        'message': {
            'to': '01066896321',
            'from': '01042149072',
            'text': '테스트 메시지'
        }
    }
    res = requests.post(config.getUrl('/messages/v4/send'), headers=auth.get_headers(config.apiKey, config.apiSecret), json=data)
    print(json.dumps(json.loads(res.text), indent=2, ensure_ascii=False))