Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Receive and send messages via an HTTP API #12

Open
jenniferzhu opened this issue Nov 21, 2017 · 2 comments
Open

Receive and send messages via an HTTP API #12

jenniferzhu opened this issue Nov 21, 2017 · 2 comments

Comments

@jenniferzhu
Copy link

Is there a way to receive and send messages via an HTTP API?

@stephenlb
Copy link
Owner

stephenlb commented Nov 22, 2017

Yes! Yes there is.

Send Message

curl https://ps.pubnub.com/publish/YOUR_PUBLISH_KEY/YOUR_SUBSCRIBE_KEY/0/YOUR_CHANNEL/0/%7B%22uuid%22%3A%222017-11-22T00%3A56%3A23.679Z%22%2C%22data%22%3A%7B%22data%22%3A%22HELLOOOOOO%22%2C%22user%22%3A%7B%22id%22%3A%22e84c26cf-413f-472e-9453-fde1a54abd0c%22%2C%22name%22%3A%22DinkySilver%22%7D%7D%7D

Example that works with the angular chat demo.

curl https://ps.pubnub.com/publish/demo/demo/0/global/0/%7B%22uuid%22%3A%222017-11-22T00%3A56%3A23.679Z%22%2C%22data%22%3A%7B%22data%22%3A%22HELLOOOOOO%22%2C%22user%22%3A%7B%22id%22%3A%22e84c26cf-413f-472e-9453-fde1a54abd0c%22%2C%22name%22%3A%22DinkySilver%22%7D%7D%7D

Receive Messages

curl "https://ps.pubnub.com/v2/stream/YOUR_SUBSCRIBE_KEY/YOUR_CHANNELS/0?tt=-1&tr=1"

Example that works with the angular chat demo.

while true ; do curl "https://ps.pubnub.com/v2/stream/demo/global%2Ce84c26cf-413f-472e-9453-fde1a54abd0c%2Cglobal-pnpres%2Ce84c26cf-413f-472e-9453-fde1a54abd0c-pnpres/0?tt=-1&tr=1" ; done

screen shot 2017-11-21 at 5 08 26 pm

@stephenlb
Copy link
Owner

stephenlb commented Nov 22, 2017

You can also pipe this into python or ruby shell script to parse the JSON and perform some additional tasks when data arrives, like save to a Database.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants