Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
messenger-api-python
Advanced tools
Python Wrapper to various APIs from Facebook Messenger Platform.
Various components used when sending messages in Facebook Messenger are wrapped into Python objects to make them reusable and easy to use.
git clone https://github.com/krishna2206/messenger-api-python.git
python -m build
pip install <package_name>.whl
Package from Pypi.org may not be the latest one, if you want the latest version of this package, install it from the GitHub repository (see above)
pip install messenger-api-python
from messengerapi import SendApi
send_api = SendApi(<page_access_token>)
send_api.send_text_message(<message>, <recipient_id>)
Note: From Facebook regarding User IDs
These ids are page-scoped. These ids differ from those returned from Facebook Login apps which are app-scoped. You must use ids retrieved from a Messenger integration for this page in order to function properly.
If
app_secret
is initialized, an app_secret_proof will be generated and send with every request. Appsecret Proofs helps further secure your client access tokens. You can find out more on the Facebook Docs
Generic Template Messages allows you to add cool elements like images, text all in a single bubble.
from messengerapi import SendApi
from messengerapi.components import Elements, Element, Buttons, Button, POSTBACK
send_api = SendApi(<page_access_token>)
elements = Elements()
buttons = Buttons()
button = Button(button_type=POSTBACK, title="My button")
buttons.add_button(button.get_content())
element = Element(title="My element", subtitle="The element's subtitle, image_url=<image_url>, buttons=buttons)
elements.add_element(element.get_content())
send_api.send_generic_message(elements.get_content() , recipient_id , image_aspect_ratio="horizontal")
from messengerapi import SendApi
send_api = SendApi(<page_access_token>)
# To send an image
send_api.send_image_attachment(<image_url> , <recipient_id>)
# To send an audio
send_api.send_audio_attachment(<audio_url> , <recipient_id>)
# To send a video
send_api.send_video_attachment(<video_url> , <recipient_id>)
# To send a file
send_api.send_file_attachment(<file_url> , <recipient_id>)
from messengerapi import SendApi
send_api = SendApi(<page_access_token>)
# To send an image
send_api.send_local_image(<image_location> , <recipient_id>)
# To send an audio
send_api.send_local_audio(<audio_location> , <recipient_id>)
# To send a video
send_api.send_local_video(<video_location> , <recipient_id>)
# To send a file
send_api.send_local_file(<file_location> , <recipient_id>)
FAQs
Python wrapper to the various APIs in Facebook Messenger Platform
We found that messenger-api-python demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.