I was wondering if it is possible to have a REST api based Parse client that can receive Push notifications.
In particular, I'm using Python for my "device" code on Raspberry Pi, and I'm using the ParsePy library which is a wrapper on top of the Parse REST api.
It doesn't look like Parse supports receiving Push notifications via the REST api (it explicitly says it doesn't support receiving Push notifications in Javascript, while the REST api section doesn't even talk about receiving push notifications).
If I've overlooked something at receiving push notifications can be achieved in a Python client, any pointers would be totally appreciated.
If it is not supported, is there any plan in the works for a Python client SDK (that would support it)?
Thanks,
Sridhar
Related
I have a running python application that needs to receive some data and process them. and I also have a PHP server that can get these data. I want to send JSON data from PHP to my python app.
anyway except running a python web server and send data to it, or insert into DB and get from DB with python?
thanks.
I tried using python cherryPy web server.
#Niklas D It would be easier to answer your question, if you can give some more context about the application or use case you want to solve.
Some further possibilities are:
Glue Code (I never did it with python and php only C++ with python, but you should be able to find examples on the internet e.g. https://wiki.python.org/moin/IntegratingPythonWithOtherLanguages#PHP )
Messaging Systems like RabbitMQ, ActiveMQ, ZeroMQ, etc.
Redis (I know you said except writing to a database, but Redis provides some features for publish subscribe https://redis.io/commands/pubsub which allows you to write to Redis from the one side and get data on the other side without polling the db all the time, which is the issue you have with using a database I guess) It's a bit easier to setup and use, than a messaging system.
TCP connection between the python and php application. https://medium.com/swlh/lets-write-a-chat-app-in-python-f6783a9ac170
If you want to send data to a python application using web protocols, i.e send POST, GET requests etc then you need to create a python web app to receive and handle those requests. Which in turn needs to be running off a webserver or you could build serverless functions to handle this, see https://serverless.com/
If you want to get data using a python application, i.e the python app sends POST and GET requests etc to your php app to ask for the JSON payload you can build an app using python's standard requests library https://docs.python.org/3/library/urllib.request.html or better still us the Requests package http://docs.python-requests.org/en/master/
Or you could do something and save the JSON file to disk and then open it with your python app. You'd need to set up scheduling or make your php app execute python code on the server... This last suggestion is a bad idea please don't unless your app is isolated and not publicly accessible or you know how to lock down your security.
I am trying to use Python 2.7 to subscribe to RSS feeds using Superfeedr.
After reading Superfeedr documentation my understanding is that a user can subscribe using XMPP or Pubsubhubbub.
I have previously worked with REST apis however I am very confused as to what I need to do in order to subscribe to feeds and receive them?
I have already installed the Superfeedr XMPP API Python Wrapper and looked into Superfeedr mashape api page and I am still struggling.
What are the basic steps a user needs to take to be able to subscribe and download RSS feeds in Superfeedr using either XMPP or Pubsubhubbub?
Sofia, I created Superfeedr.
The first step for you is to pick between XMPP and PubSubHubbub. These are 2 APIs with different purposes.
Since you previously worked with REST APIs, I suggest you stick to PubSubHubbub, which you'll probably be a lot more familiar with.
The most important concept of this API is that it's a webhook based system. This means that not only will you send us requests to subscribe to feeds, but we will also send you requests when the feeds have been updated. We will send requests to an URL on your application, named the webhook or hub.callback.
Finally, rememebr that even if you can indeed retrieve (download) the content of an RSS feed from Superfeedr, the recommended way is to actually wait for us to send you that data (via the webhook).
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. :)
I have a Python/Flask backend and an Angular frontend for my website. At the backend there is a process that occasionally checks SQS for messages and I want it to push a notification to the client which can then in turn update an Angular controller. What is the best way to do this my existing technologies?
To be able to push to the client, you'll have to implement web socket support in some fashion. If you want to keep it in python/flask, there is this tutorial on how to do that with gevent:
http://www.socketubs.org/2012/10/28/Websocket_with_flask_and_gevent.html
In that article, Geoffrey also mentions a SocketIO compatible library for python/gevent that may allow you to leverage the SocketIO client-side JS library, called "gevent-socketio".
That may reduce how much work you have to do in terms of cross-browser compatibility since SocketIO has done a lot of that already.
Here is a pretty good tutorial on how to use SocketIO in AngularJS so that you can notify the AngularJS model when an event comes in from SocketIO:
http://www.html5rocks.com/en/tutorials/frameworks/angular-websockets/
If you don't want to host the web socket backend, you could look to a hosted service like PubNub or Pusher and then integrate them into AngularJS as a service. You can communicate with these services through your Python app (when the SQS notification happens) and they'll notify all connected clients for you.
I know this is a bit late, but I have done pretty much exactly what you ask for (though without Angular).
I ended up having a separate process running a websocket server called Autobahn, which listens to a redis pub/sub socket, the code is here on github
This allows you to send push notifications to your clients from pretty much anything that can access redis.
So when I want to publish a message to all my connected clients I just use redis like this:
r = redis.Redis()
r.publish('broadcasts', "SOME MESSAGE")
This has worked fairly good so far. What I can't currently do is send a push notification to a specific client. But if you have a authentication system or something to identify a specific user you could tie that to the open websockets and then be able to send messages directly to a specific client :-)
You could of course use any websocket server or client (like socket.io or sock.js), but this has worked great for me :-)
I have a python GAE service, and I want to push notifications from the server to devices. The tutorial available for GCM is written for Java, and runs on ant+Tomcat/Jetty+JAE. I was under the impression that GCM would be a language-agnostic web service, and that I would be able to send push notifications regarding of my server-side platform.
Was I mistaken about GCM being compatible with my python GAE
backend?
If I CAN use it with my existing server, what instructions
can I follow (or adapt) to get started with sending notifications to
a mobile client?
Sure you can. GCM has a JSON REST API that you can work against. First you need to register you project here: http://developer.android.com/google/gcm/gs.html.
You basically do this:
Acquire you API key from http://developer.android.com/google/gcm/gs.html#access-key
Construct your payload, a dict containing registration_ids, data etc
Using url.fetch https://developers.google.com/appengine/docs/python/urlfetch/ to send the data as a JSON string to the GCM API
Here's another question with some code. Google Cloud Messaging HTTP Error 400: Bad Request and a blogpost (in not english, i think spanish. but there some sample code) http://pforray.wordpress.com/2012/07/05/ejemplo-gcm-en-appengine-python/
Use gcm-client
pip install gcm-client
Reference:
https://pypi.python.org/pypi/gcm-client/
Here you can find a module for Python interface for sending push notifications via Pushwoosh.
https://github.com/dbtsai/python-pushwoosh
You can use it for sending messages via Pushwoosh (it's free) or adapt it for your needs.