How to mimic Facebook's "Like" feature in WebSocket - java

I developed a proof of concept application that uses WebSocket to mimic the functionality of Facebook.
If on Facebook someone "likes" a picture, I see the notification on my page right away without me refreshing the page. Is this being done by WebSocket? What strategy is this adopting - pub/sub?
The application I developed is in Java and I came across Atmosphere Framework. I'm not sure which sample I should review from their vast list of examples on GitHub to accomplish what I'm trying to do.

Without Facebook API, we'll have to find a certain way:
On a dedicated server, since you are not using Facebook API, I would use an auto refresher that refreshes the Facebook page every interval of time and put the number of likes in a database.
Then, use AJAX on your website that communicates with a PHP file on server.

Related

How does a website and android app connects?

I am new in android development and i have been developing android apps using cloud firebase but how can i make an app for a website which is not using firebase. I know i need to connect to its database but what if the website is hosted on wordpress.com which does not provide phpmyadmin. So is there any other way? I know there is something called rest api. Can we use rest api in websites that are developed in some framework like codeignitor? Please explain what rest api is and is there any other way to get the data for our app? Please let me know thank you.
This is going to be tough. Usually, an application communicate with a web service. A web service may be a Rest API, Firebase or any hosted service that can provide data (I don't know all of the subtilities of it).
Explaining to you how all of this works wouldn't work here as it will be objective as every application have different needs and every developper have preferences on how he want his application to communicate with the world.
One thing you should avoid at all costs would be to access an online database directly from your application as it is a huge security flaw.
Here are some links that will help you understand better all of this.
REST API concepts and examples
Make an HTTP request with Android
Web services explained
I am well aware that stackoverflow answer shouldn't be mainly links but I still thinks that they will be relevant to your problem. Be aware that this answer doesn't even cover a little part of communication between an application an a webservice. You'll have to learn that by yourself, using courses and tutorials.

How to make an API to interact with my app

How can I make an online server to access API's and handle requests? Then how can I have my android app access this online server to make requests?
I have an android app that I am building for a school project. This app will need to use multiple APIs to gather information to display to the user. However I don't want to allow people to decompile to source code and take my API keys. My plan is to build an online application that will do all of this work on the server side. This way the user only submits a query and the server sends information in response to their request. This will speed things up for the user and keep the keys from being accessed by other individuals.
Steps I think I need to take.
Set up server to access the API's
Make app access online server through HTTP requests
3....
4...
I have a very general concept in my head, but I'm not sure where to begin. If I'm wrong on any part of this question please correct me.
I do plan on moving this to the app store in the future.
edit: Do you know of tutorials that show the building of the API and then loading it to Amazon AWS or another server?
There are many options when building restful services for api consumption. You could start with php, which is the easiest to start with. Here is a nice tutorial that takes you through the initial stage all the way to the end of building login system for android using mysql and php as the server language. It contains the barebone details of setting up the infrastructure and logic. I think from there you manipulate and go further.
https://www.androidhive.info/2012/01/android-login-and-registration-with-php-mysql-and-sqlite/
check out java rest easy, it is a nice tool to use to build web API's. You can host it for cheap at red shift or amazon using their pay what you use billing.
The cheapest way for you to host your REST API is to use Amazon's API Gateway. You pay for what you use and pay nothing if it is not being used. API Gateway plays very nicely with Amazon's Lambda service that allows you to run discrete code units - again, you only pay for what you use. Lambda itself plays nicely with Amazon's pay-as-you go NoSQL datastores (SimpleDB and DynamoDB).

Accessing Data from Python GAE Datastore using Java

I have set up a Google App Engine website project using Python, with the webapp2 framework. It's neat and seems to be working perfectly. I can run queries in the backend of my website using python.
However, recently I've decided I want to have an Android (and maybe iOS) app as well as a website. The app will almost clone the website. Now, I have no idea how to query this data or access the datastore using Java, since up till now it's all been using the ndb import in Python.
How exactly would I approach this? I doubt that I need to create a new project in Java on GAE?
Has it something to do with Remote API? Looking into that now. And if so, it seems like none is available for Swift language.
Should I consider using a different Database system, and forget about GAE?
I only wish to read the data in Java, not write to the database.
For this you can use Cloud Endpoints. You expose the information you want on an API, and you consume it from iOS or Android. Here there is a tutorial that covers it.

Facebook API and Facebook Connect using Java?

New to Facebook API and Facebook Connect.
Found the Facebook Java API open source library on Google Code...
I am really excited that there's an API pre-written in Java for it!
Am interested in writing a server side Java layer which uses REST to be able to access a user’s Facebook Friends List, their wall, send them messages in-network, etc.
Downloaded the binary and unfortunately, I haven't found any sample or demo code when I unzipped it...
Question(s):
(1) Does this library support Facebook Connect?
(2) What is the best way to get start using Facebook Connect with server side Java?
(3) Since I am building middleware, do I still have to create a sample app on the online Facebook Developer page?
(4) What should I include in my (am a newbie in Maven) pom.xml in order to get started?
Use RestFB, that seems to be the inofficial FB Java Api:
http://restfb.com/
(There is no official FB Java Api anymore)
As far as I know, that library is broken. I couldn't get authentication to work with the latest version.
In my search for alternatives i found the "TinyFBTagLibrary" http://www.socialjava.com/ --
Yes, it requires just about a billion extra libraries to run, but it offers a simple way to execute facebook API calls in java that ISNT BROKEN (once again, as far as I know). My advice is to ignore all of the predefined tags for use in jsp and scroll down to the bottom to see how to use the TinyFBClient.call/getResponse when you need to get information.

implementing a AJAX chat site

I want to implement a chat site with following features:
Direct one-on-one chat with a randomly picked stranger
If my conversation partner gets disconnected, I should be shifted to different stranger
In short, I want to imitate http://omegle.com/
Which language is best suited to this task? Jsp and Java? PHP? ASP? Others?
Should all of the messages go through the web server, or is there a better approach?
You may want to look into Google Web Toolkit (GWT). Ryan Dewsbury's book "Google Web Toolkit Applications" actually runs you through the process of writing a basic chat application.
GWT lets you write Java code that is compiled into Javascript for AJAX applications.
I wrote an AJAX Chat tutorial years ago at:
http://www.dynamicajax.com/fr/AJAX_Driven_Web_Chat-271_290_291.html
I also did a JSON version of it too:
http://www.dynamicajax.com/fr/JSON_AJAX_Web_Chat-271_290_324.html
Those are written in PHP but the back end is really simple so you can port it to whatever language you want easily. Here's a version that I converted to ASP.NET
http://www.dynamicajax.com/fr/AJAX_Web_Chat_ASP_NET-271_290_328.html
It works pretty much like Omegle, all you need to do is setup the code to randomly select a stranger.
I recently created a chat script using PHP + AJAX. Yes, all of my chat messages went through the server because it used AJAX and server-side PHP scripting to deliver the messages to the recipient(s).
For an example of a PHP chat script, see:
http://www.phpfreechat.net/

Categories

Resources