I have recently been introduced to how awesome Web Sockets are. I am currently making a program that, every minute, pings the YouTube Data API and gets data from a list of channels to check if they have uploaded a new video. I am also doing a similar thing with Twitch.tv live streams. I have just started using Twitch4J, which uses WebSockets to get the data from Twitch. I am wondering if YouTube supports WebSockets at all or has a similar program like how Twitch4J works with Twitch?
Appreciate any help or guidance.
You haven't talked about WebSub which is supported by YouTube Data API v3 (and works) for videos feed: https://developers.google.com/youtube/v3/guides/push_notifications
Indeed it's not using WebSocket but it's similar because the server send notifications to a remote server instead of repeating (useless) requests to YouTube very regularly.
Related
I want to implement fcm push notification like other websites facebook,amazon etc. for my web app built on spring and Jsp. I go through the all google docs but didn't find any. How other website ask user to send them notification and after allowing they start sending?
HTTP, which has a request-response model, is ill suited for the job. You asked how some applications do it, well the older ones create a HTTP channel which remains open for the application lifetime. The backend pushes new data to this channel as and when new events occur.
Any application that is reasonably modern uses websockets. See the WSS protocol. There are libraries built around this protocol to make it easier to consume, such as socket.io. You should read the MDN reference as well: https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_client_applications
I recently started developing my first web application with Spring and I'm stuck with a question I could not really find an answer to. What I have is a simple Spring MVC application running in tomcat which provides data in form of JSON, XML or binary via REST. This service is consumed by two clients I developed, a simple Java desktop application and an Android app. So far the clients only got information about new data by polling.
What I want now, is a way for the server to send notifications/messages to the clients when new data is available. For the Android client it would be good if the notifications could received anytime, not only when the app is currently open of course. I found lots of information for JavaScript client code but very little really useful, up-to date input about what the options for java and android clients are.
It would be really great if someone could give me some idea what would be the best way to achieve what I want (ideally something which integrates well with Spring on the server side), what protocols/libraries/frameworks to use, maybe even point me to some example or tutorial, how to implement this on server and client side.
Thanks in advance for any input.
For android or mobile devices, Google Cloud Messaging is the preferred way of sending messages to applications running on devices.
Example : spring gcm server side project and a sample tutorial.
For desktop apps, either poll regularly the server or run something in background like crontab or active-mq to check the messages and start the desktop app.
WebSockets are the best solution. check the implementation in java in the server side
I was wondering, is there any way that you could add a subscriber to a YouTube Channel, programmatically in Java?
Is it simple enough that it could be likethis.addSuscriber("username", "password", "suscriberTo");?
Would it have to use the YouTubeAPI, would it be possible with HTTP Requests through Java?
Doing this with plain java would be pain for you. You will have to manage the whole web service authentication process, data mapping, ... by yourself.
Google offers it's own Java API for YouTube:
YouTube Data API Client Library for Java
You will find a GitHub repository delivering you examples how to access youtube web services by using java and for your question topic also a dedicated example of managing subscriptions:
com.google.api.services.samples.youtube.cmdline.data.AddSubscription.java
I'm new in android and i want to know if there is some server / web service online that o can use to update and communicate with my app?
example: I have the app "message" in 5 phones so I want to communicate with all of them, if the phone 1 send a message all device must receive notification.
There is something that I can use maybe free?
You have many options to accomplish this goal, and most provide some free level of support.
In general if you want to "push" notifications to android devices, you can either directly use or use some provider that uses Google Cloud Messaging.
Using this approach directly means you need some web server to send request to, which will then forward a request to Google, which will then forward your "message" to the devices you want to reach. There are many options for free hosting of (smallish) web services. IBM's BlueMix and Heroku come to mind. So if your are comfortable writing web apps, this might be a good choice. I have used both (for Ruby on Rails backends to mobile apps) and found both very good, but am currently using Bluemix.
I believe Bluemix along with Parse also offer mobile data storage and easy access to Push notifications to both Android and iOS. I am currently using Bluemix via Ruby on Rails and pushing messages directly to devices via GCM and don't have much experience with those particular offerings.
I apologise for the very general question but I'm looking for some advice. I have two products that I have created for a project. An android app and a website service. I want the android app to be able to connect to a PostgreSQL database in order to authenticate user login and submit a small amount of data.
The data on the PostgreSQL database will then be produced on the website. Simples!
I'm wondering if there are some tutorials or discussions that provide a simple solution to this. I've looked at loads of forums which mention using a lot of complicated protocols, frameworks, etc.
I'm just looking for some nice efficient android examples on how to achieve this.
Any advice would be appreciated.
You should not worry about android and PostgreSQL communication because they won't communicate directly.
All what you need is a simple HTTP communication between your android and the web service to send and receive information (e.g. credential for authentication)
Your web service should take care of storing and retrieving data from the database