Open guitmz opened 7 years ago
for entry in data['entry']:
recipient_id = entry['messaging'][0]['sender']['id']
received_text = entry['messaging'][0]['message']['text']
if received_text == '/hnews':
message_params = {
'title': 'Hacker News',
'subtitle': 'Hacker News Website',
'item_url': 'https://news.ycombinator.com/',
'image_url': ''
}
return fb.send_link_message(recipient_id, message_params)
should be
for entry in data['entry']:
recipient_id = entry['messaging'][0]['sender']['id']
received_text = entry['messaging'][0]['message']['text']
if received_text == '/hnews':
message_params = {
'title': 'Hacker News',
'subtitle': 'Hacker News Website',
'item_url': 'https://news.ycombinator.com/',
'image_url': ''
}
return fb.send_link_message(recipient_id, message_params)
else:
return fb.send_message(recipient_id, 'Would like to receive a random Hacker News? (Type: /hnews)')
I would also not return values here but log them on the stdout instead because if there are multiple entries in data['entry']
, the code will stop on the first nevertheless.
In
example.py
, the loop at line 18 is incorrect. The code in line 22 should be inside this loop but it's outside.