def main(): try: auth_obj = Token(AUTH_FILE) except Exception as e: raise ValueError(e) msg = ' '.join(sys.argv[1:]) req = line_notify(auth_obj.get_data(LINE_AUTH_KEY), msg) req_msg = RESPONSE_HEADER.get(req) if not req_msg: req_msg = RESPONSE_HEADER.get(0) print(f'[LINE] {req}: {req_msg}')
def __init__(self, access_token=None, access_token_secret=None, consumer_key=None, consumer_secret=None, key_cert=None, header_auth=None): # Determine the appropriate signing type if key_cert is not None: self.signature = CustomSignatureMethod_RSA_SHA1() self.signature.key_cert = key_cert else: self.signature = CustomSignatureMethod_HMAC_SHA1() """ Consumer is compulsory, while the user's Token can be retrieved through the API """ if access_token is not None: self.token = Token(access_token, access_token_secret) else: self.token = None if consumer_key is None and consumer_secret is None: consumer_key = self.consumer_key consumer_secret = self.consumer_secret if header_auth is not None: self.header_auth = header_auth self.consumer = Consumer(consumer_key, consumer_secret)
def main(): global win global auth_obj global status try: auth_obj = Token("auth.json") except Exception as e: tk.messagebox.showerror("Error", e) sys.exit(1) win = tk.Tk() win.title("LiNe nOtIfy Sender") label = tk.Label(win, text="Message content:", anchor=tk.W) label.pack(fill=tk.BOTH) text = tk.Text(win) text.pack(fill=tk.BOTH) button = tk.Button(win, text="Send", command=lambda: send_text(text)) button.pack() status = tk.Label(win, text="Ready", anchor=tk.W) status.pack(fill=tk.BOTH) win.mainloop()
def run(data, ws): username = data.pop('username') password = data.pop('password') token = Token(username, password) man_number = data.pop('manNumber') woman_number = data.pop('womanNumber') city = data.pop('city') # city_query_list = city.split(' ') # city_list = [get_city_id(token, city_name) for city_name in city_query_list] # data['hopeAdressStr'] = ','.join([str(each_city[0]) for each_city in city_list]) # data['regionName'] = ','.join([str(each_city[1]) for each_city in city_list]) data['cityId'], _ = get_city_id(token, city) # email = data.pop('email') data['startDegreesName'] = get_degrees_name(data.get('startDegrees')) data['endDegreesName'] = get_degrees_name(data.get('endDegrees')) # 原网站拼写错误 data['endDegress'] = data.pop('endDegrees') logger.info(('query:', data)) folder_id, folder_name = get_folder_id(token) run_by_gender(token, man_number, '男', data, folder_id, ws) run_by_gender(token, woman_number, '女', data, folder_id, ws)
def __init__(self, client_id=None, client_secret=None): if client_id and client_secret: self.token = Token(client_id=client_id, client_secret=client_secret) else: config = Config() self.token = Token(client_id=config.attrs['CLIENT_ID'], client_secret=config.attrs['CLIENT_SECRET']) # Set the bearer for each HTTP request regardless if OAuth is # required or not. self.headers = { 'Authorization': '{token.token_type} {token.access_token}'.format(token=self.token), 'Content-Type': 'application/json', }
def __request_token(code): client_id = os.environ.get('CLIENT_ID') or config.CLIENT_ID client_secret = os.environ.get('CLIENT_SECRET') or config.CLIENT_SECRET uri = 'https://github.com/login/oauth/access_token?client_id=' +\ client_id + '&client_secret=' + client_secret + '&code=' + code header = {'Content-type': 'application/json'} r = requests.post(uri, headers=header) d = dict(s.split('=') for s in r.content.split('&')) if 'error' in d: return None if 'access_token' in d: return Token(d['access_token']) return Token('')
def __init__(self, access_token=None, access_token_secret=None, consumer_key=None, consumer_secret=None): """ Consumer is compulsory, while the user's Token can be retrieved through the API """ if access_token is not None and access_token_secret is not None: self.token = Token(access_token, access_token_secret) else: self.token = None if consumer_key is None and consumer_secret is None: consumer_key = self.consumer_key consumer_secret = self.consumer_secret self.consumer = Consumer(consumer_key, consumer_secret)