python access token_Python config.ACCESS_TOKEN属性代码示例

本文整理汇总了Python中config.ACCESS_TOKEN属性的典型用法代码示例。如果您正苦于以下问题:Python config.ACCESS_TOKEN属性的具体用法?Python config.ACCESS_TOKEN怎么用?Python config.ACCESS_TOKEN使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在模块config的用法示例。

在下文中一共展示了config.ACCESS_TOKEN属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: get_like_count_by_url

​点赞 3

# 需要导入模块: import config [as 别名]

# 或者: from config import ACCESS_TOKEN [as 别名]

def get_like_count_by_url(self, id_urls):

d = {}

#TODO: put in the token

for sub_list in self.chunks(id_urls, 3):

print "Processing" + ",".join(sub_list)

url = "https://graph.facebook.com/?%s" % (urlencode({'ids': ",".join(sub_list), 'fields': 'og_object{engagement{count}}', 'access_token': ACCESS_TOKEN}))

r = requests.get(url)

o = r.json()

print o

d.update(o)

if "error" in o:

raise Exception("Too many Requests")

time.sleep(3)

print d.keys()

counts = {}

for k in d.keys():

o = d[k]

oj = o.get("og_object", {"og_object": {"engagement": {"count": 0}}})

e = oj.get("engagement", {"count": 0})

counts[k] = e["count"]

return counts

开发者ID:howawong,项目名称:appledaily_hk_hot_keyword_pipeline,代码行数:23,

示例2: search

​点赞 3

# 需要导入模块: import config [as 别名]

# 或者: from config import ACCESS_TOKEN [as 别名]

def search(input, sender=None, postback=False):

if postback:

payload = json.loads(input)

intent = payload['intent']

entities = payload['entities']

else:

intent, entities = process_query(input)

if intent is not None:

if intent in src.__personalized__ and sender is not None:

r = requests.get('https://graph.facebook.com/v2.6/' + str(sender), params={

'fields': 'first_name',

'access_token' : os.environ.get('ACCESS_TOKEN', config.ACCESS_TOKEN)

})

entities['sender'] = r.json()

data = sys.modules['modules.src.' + intent].process(input, entities)

if data['success']:

return data['output']

else:

if 'error_msg' in data:

return data['error_msg']

else:

return TextTemplate('Something didn\'t work as expected! I\'ll report this to my master.').get_message()

else:

return TextTemplate('I\'m sorry; I\'m not sure I understand what you\'re trying to say sir.\nTry typing "help" or "request"').get_message()

开发者ID:voqz,项目名称:Rero,代码行数:26,

示例3: reply

​点赞 2

# 需要导入模块: import config [as 别名]

# 或者: from config import ACCESS_TOKEN [as 别名]

def reply(user_id, msg):

data = {

"recipient": {"id": user_id},

"message": processReply(msg)

}

url = "https://graph.facebook.com/v2.6/me/messages?access_token="

resp = requests.post(url + ACCESS_TOKEN, json=data)

print(resp.content)

开发者ID:manparvesh,项目名称:BotDude,代码行数:10,

示例4: webhook

​点赞 2

# 需要导入模块: import config [as 别名]

# 或者: from config import ACCESS_TOKEN [as 别名]

def webhook():

if request.method == 'POST':

data = request.get_json(force=True)

messaging_events = data['entry'][0]['messaging']

for event in messaging_events:

sender = event['sender']['id']

message = None

if 'message' in event and 'text' in event['message']:

if 'quick_reply' in event['message'] and 'payload' in event['message']['quick_reply']:

quick_reply_payload = event['message']['quick_reply']['payload']

message = modules.search(quick_reply_payload, sender=sender, postback=True)

else:

text = event['message']['text']

message = modules.search(text, sender=sender)

if 'postback' in event and 'payload' in event['postback']:

postback_payload = event['postback']['payload']

message = modules.search(postback_payload, sender=sender, postback=True)

if message is not None:

payload = {

'recipient': {

'id': sender

},

'message': message

}

r = requests.post('https://graph.facebook.com/v2.6/me/messages', params={'access_token': ACCESS_TOKEN},

json=payload)

return '' # 200 OK

elif request.method == 'GET': # Verification

if request.args.get('hub.verify_token') == VERIFY_TOKEN:

return request.args.get('hub.challenge')

else:

return 'Error, wrong validation token'

开发者ID:swapagarwal,项目名称:JARVIS-on-Messenger,代码行数:34,

示例5: search

​点赞 2

# 需要导入模块: import config [as 别名]

# 或者: from config import ACCESS_TOKEN [as 别名]

def search(input, sender=None, postback=False):

if postback:

payload = json.loads(input)

intent = payload['intent']

entities = payload['entities']

else:

intent, entities = process_query(input)

# TODO: Needs to be refactored out

try:

keen.project_id = os.environ.get('KEEN_PROJECT_ID', config.KEEN_PROJECT_ID)

keen.write_key = os.environ.get('KEEN_WRITE_KEY', config.KEEN_WRITE_KEY)

keen.add_event('logs', {

'intent': intent,

'entities': entities,

'input': input,

'sender': sender,

'postback': postback

})

except:

pass # Could not stream data for analytics

if intent is not None:

if intent in src.__personalized__ and sender is not None:

r = requests.get('https://graph.facebook.com/v2.6/' + str(sender), params={

'fields': 'first_name',

'access_token': os.environ.get('ACCESS_TOKEN', config.ACCESS_TOKEN)

})

if entities is None:

entities = {}

entities['sender'] = r.json()

data = sys.modules['modules.src.' + intent].process(input, entities)

if data['success']:

return data['output']

else:

if 'error_msg' in data:

return data['error_msg']

else:

return TextTemplate('Something didn\'t work as expected! I\'ll report this to my master.').get_message()

else:

return TextTemplate(

'I\'m sorry; I\'m not sure I understand what you\'re trying to say.\nTry typing "help" or "request"').get_message()

开发者ID:swapagarwal,项目名称:JARVIS-on-Messenger,代码行数:42,

示例6: webhook

​点赞 2

# 需要导入模块: import config [as 别名]

# 或者: from config import ACCESS_TOKEN [as 别名]

def webhook():

if request.method == 'POST':

data = request.get_json(force=True)

messaging_events = data['entry'][0]['messaging']

for event in messaging_events:

sender = event['sender']['id']

message = None

if 'message' in event and 'text' in event['message']:

if 'quick_reply' in event['message'] and 'payload' in event['message']['quick_reply']:

quick_reply_payload = event['message']['quick_reply']['payload']

message = modules.search(quick_reply_payload, sender=sender, postback=True)

else:

text = event['message']['text']

message = modules.search(text, sender=sender)

if 'postback' in event and 'payload' in event['postback']:

postback_payload = event['postback']['payload']

message = modules.search(postback_payload, sender=sender, postback=True)

if message is not None:

payload = {

'recipient': {

'id': sender

},

'message': message

}

r = requests.post('https://graph.facebook.com/v2.6/me/messages', params={'access_token': ACCESS_TOKEN}, json=payload)

return '' # 200 OK

elif request.method == 'GET': # Verification

if request.args.get('hub.verify_token') == VERIFY_TOKEN:

return request.args.get('hub.challenge')

else:

return 'Error, wrong validation token'

开发者ID:voqz,项目名称:Rero,代码行数:33,

示例7: __init__

​点赞 2

# 需要导入模块: import config [as 别名]

# 或者: from config import ACCESS_TOKEN [as 别名]

def __init__(self):

listener = StListener()

auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)

auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)

self.stream = tweepy.Stream(auth, listener)

self.api = tweepy.API(auth)

开发者ID:melizeche,项目名称:comentaBOT,代码行数:8,

注:本文中的config.ACCESS_TOKEN属性示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值