Python to Facebook message, no xmpp authorisation - python

I am trying to develop a python script that will automatically send a private facebook message to one user.
I have followed the procedure here but this uses the xmpp access tokens.
From what I have read, this is no longer supported.
Does anyone know of a suitable work around?
Thanks for any help

You can only send messages with the official ways (Send Dialog, Facebook Messenger, ...).
Take a look at the Send Dialog: https://developers.facebook.com/docs/sharing/reference/send-dialog
Most likely it´s what you need.

Related

How to send push notifications to iOS using a python api

I have create a webscraper that sends notifications to my phone whenever certain events are detected. So far I have achieved this by sending emails through the sendgrid api. Its a pretty nice service, and it is free, but it clutters up the mailbox quite a bit.
In stead I’d like to send messages directly to the iOS notification bar. Does anyone here has experience with sending push-notifications to iOS and can point me in the correct direction? I would be happy with a subscription service, but would off course prefer a solution that does not require a third party if it is possible.
I have tested PushNotifier, but I found it a bit clunky, and the notifications are neither customisable or beautiful. Its also not a free service, which would have been a great plus.
Maybe you should check out pushover.net. They have a simple WebAPI to send customized notifications to iOS devices.
See https://support.pushover.net/i44-example-code-and-pushover-libraries#python for code samples.

Suggestion: The best way to send messages on Facebook without getting banned using python

I'm using a python script that monitors a website and sends me messages on Facebook if there is any specific updates.
I have tried a module which called 'fbchat', so simple and so easy, but the problem is that I'm using real Facebook accounts and somehow Facebook detected that it's a bot and banned that profile, even if I have made random pauses in my code.
I know that I can do make those notifications through emails, but for me Facebook messages are better... Any ideas about how can I make it possible (maybe through bots!!)?
Thank you!
First take a look at which parameters(headers and payloads) the POST method takes(using network tools in google chrome for example), and try again with as many parameters as possible, while also using a session so cookies are enabled as well.
Different websites use different methods of detecting bots, and you'll just have to test and see what works.
P.S: take a look at this answer for more info.
Multiple Accounts are not allowed on Facebook, and there is no (allowed) way to send messages between users. You can only send messages from Pages to Users, and only if the User started the conversation. You can find more information about that in the docs: https://developers.facebook.com/docs/messenger-platform/

Gathering bug reports?

Premise: I am a beginner in search for an easy way to send bug reports from users over sea.
I've made a script for some friends that are living on the other side of the sea (US - EUROPE)... I will like to gather automatic bug reports whenever they happen. So my first idea was to send myself an email with the smtplib module. It works fine when testing home, but as soon as the sender "sends", my email provider (gmail) blocks the connection because of course, its from an "unknown device". I've already enabled "Allow less secure apps" as someone suggested but with no avail.
What I am searching its a simple way of dealing with this.
Yes I could make the script to ignore the error if the email its not being sent, and then go into my google account and enable those devices so at least it will work from the second run..
But it doesn't seem what a programmer would do in this case. I am learning so a solution withing the language is what I am after.
A different provider that has no restriction its also a good start but I tried Yahoo, Live, Yandex but I couldn't make them work. Are there any?
So my question is: how others do? what is the best solution for some one like me?
I've read about sentry or other error/bug tracking but its obviously way too much for want I need
You should certainly not incorporate e.g. Gmail credentials in the code that is remotely executed on devices you do not control, given I understand correctly the Gmail less secure device issue happens as every "user" is running this code and using your credentials. This holds true for any other provider.
Now this won't exactly be simple but one way to go about it would be to create a server side API endpoint that can accept HTTP(s) or any other protocol requests that then will authenticate in a little more secure way on the server side with Gmail.
The concept for emails is:
Bug > Python Script > API call > Email
This could be implemented using Python on the API side (Flask e.g.) using an AWS Lambda Function with Amazon API Gateway, but again that is something to get through and understand by itself which will take a good chunk of time.
You need to touch a lot of concepts, like auth tokens to make this really secure.
Could you elaborate a little on where the code needs to run and if you are willing to try AWS or any other cloud provider, or would have access to an internet connected server ? This makes it easier to provide you with a full example on the solution in a hackish way while I would highlight the problems you could face on the security side.
I understand that this is not the way to go but as for my needs and my level of experience it works for me!
Yandex allows you to send email from different ip so Yandex is the way to go. What I was doing wrong in the first place was to use the wrong port (587 instead of 465)

How do you register a python-based client with GCM (Google Cloud Messenger) to get a registration_id for the device?

I have been trying to figure out how to use one of the following python packages to create a python-based client that is capable of receiving XMPP-based messages via Google Cloud Messenging.
https://github.com/geeknam/python-gcm
https://github.com/daftshady/py-gcm
https://pypi.python.org/pypi/gcm-client/
https://github.com/pennersr/pulsus
From all I can see, (e.g., the documentation for gcm-client), these packages can send messages to other clients that are identified by registration_id. But how do I get a registration IDs for each client in the first place? In other words, how do I register the client-app that I am creating so that it can receive messages?
It is starting to seem to me that these are not clients per-se, but just libraries that can be used to push messages to clients. I hope that I am wrong about that and just missing a key concept.
Each client application has to call the getRegistrationId() to get the registration id once. Then they can receive messages. A more detailed function call is here
I hope this give you an idea on client devices. :)

Determine if an XMPP user is online or not

I'm using the xmpppy library to write an XMPP client that can chat with users. It has its own XMPP user account and needs to know if a given user is online. However, the documentation is a bit sparse on how to do this. What would you recommend?
The only solution I've seen thus far is to start up a daemon before the XMPP server starts and monitor all presence messages that are sent out - then a user is said to be online if they've sent the "I'm online"-type message but not the corresponding "I'm logging off" message. However, being new to XMPP in general, I would think there would be a nicer way to do this.
The simple way is to support "subscribe" presence message -- this lets another user check if you're currently present (if they don't already know) by a "subscribe" attempt. Check this useful guide to get started, and the standard for many more important details (esp. on protecting your privacy, if needed, from subscribe requests from user you don't know).
There are basically three ways to connect to an XMPP server: as a client (which you've done), as a component, and as another server. The server-to-server type (s2s) is just a federated connection, very much like how mail servers exchange email with each other.
Alex described how clients keep track of presence. XMPP requires me to approve that you can receive my presence information and vice versa. For your bot this means for you to keep track of who's online the end users need to accept your presence requests. It also means that you can respond to the user's presence requests and keep them informed about if your bot is up or not.
The last way is as a trusted component, and only works if you're running the server. i.e. if you're trying to do this on the jabber.org server, you're out of luck, because you're not running that server. The upsdie is you can have access to the internals of the XMPP server, like pulling lists of everyone who's online. The downside is your component / bot implementation is going to be different for every server implementation.

Categories