This question already has answers here:
Making Android chat application from scratch
(6 answers)
Closed 8 years ago.
I need to send messages between two Android's running my app, with a PHP server in between. Devices are identified by phone number, but I have no clue how to send the message
I've looked into sockets and the sorts but do not really know how to work it with PHP
Anyone point me in the right direction?
I would look into the idea of RESTful apis, here is a start. Essentially what you do it have different urls that the android app can send data to. Sending data to one might make a chat between two androids and return the chat id. Then you can send data to another to send a chat message, including that chat id. The only thing you want to be careful of is security. A general rule when making a api like this is, asume people will find these urls, and asume people will use these malicously. So incorperate some sort of security, look at how other peeople do it, like Google.Another important concept in RESTful apis is the idea of http verbs. In http you can commonely, GET(What your browser does most of the time), POST, PUT, and DELETE. This allows you to have 1 url and many actions, like so
GET /users/chats - returns users chats
POST /users/chats - creates a chat
PUT /users/chats - updates a chat
DELETE /users/chats - deletes a chat
Security
Generally when I create a RESTful api I use a token secret combination. For anyone to use my API they have to send a token with it, along with a secret. If the token they send and the secret match, then they can use the api.
Related
I need to create an app which get's it's displayed data from FIX protocol in real time.
How would be best practice to accomplish this?
Should the mobile app read directly the FIX data?
Should I put a server in between to transform the FIX data to JSON or something more prepared for service consumption? And if so... how would I do it to not lose the real time? Creating a websocket in Java which for the mobile apps to call and that websocket would transform the FIX data to JSON that way?
I never worked with the FIX protocol before by the way.
So like, the question is, can you put a FIX client on a mobile phone? I guess you can, and I am sure it will happen soon.
Yes, anything can read FIX data, it's simply text stream name value pairs, where the name is a numbered tag to identify some particular financial data or process, as agreed between the FIX community as a whole, or between direct counterparties using messaging data dictionaries.
These days you could try using SBE throughout, including at the mobile client, but for now current practise is yes, to use JSON for client endpoints (where the JSON name is not a FIX tag but the underlying FIX field name so it's easier for people to understand) and pass JSON messages to the mobile device in some kind of REST data processing.
So yeah, you'd have a FIX server (if you are new to FIX try QuickFix) to connect with your provider. Then what you need between that server and mobile clients is asynchronous messaging. Consider a quote request is not a simple request / response where you can block the request thread until a single response is received, it's a request followed by a stream of many responses. So you want an event handler style to route the responses back to clients asynchronously. With many mobile UI clients making requests and receiving responses you need to demultiplex the responses from the 1 FIX server out to the many mobile clients. That's something that QuickFIX itself kind of already does using a session layer. You need to do the same using sessions or identifiers in the messages you're passing around.
Yeah I guess websockets are intended to be that solution for real time. You could write a native mobile app though, using something like node or react to handle the message events.
Scenario:
I am planning to build a system that has 2 components. A Web App (Angular) that would push some data to Firebase. Before the data gets pushed , I want it to get validated by a server-side Java code. The data getting pushed to Firebase is fed to an Android application that consumes the data from Firebase. The Android user can perform some actions like changing the state of data. Before the data gets changed again there should be a server side code to validate it.
Question:
Where does the server-side code reside? Do we need a third party Web App hosting service other than Firebase?
If my code is in Java 7, what can be the possible options available?
If at all we use a third party server, how does the server communicate with a Firebase server?
Also can you please help me understand (if possible) how can we make sure that the data getting pushed to Firebase server gets validated by the server-side code before getting pushed?
firebaser here
You can interact with the Firebase Database through its Java SDK.
Firebase does not currently provide a way for you to run your (Java) code on our servers. We've covered this many times already, so I recommend reading up here: Server Side Calculation using Firebase
So you'll indeed have to host that code at a third party. Recommending a specific host is off-topic on Stack Overflow, but there are undoubtedly a lot of results of you search for Java hosting.
A common way to have server-side validation before sharing the data publicly is to have two separate lists.
moderationList
-K.....1
title: "how can we add a server side java code in firebase"
body: "Scenario: I am planning to build a system..."
messageList
-K.....2
title: "Firebase and backend logic"
body: "I am parse.com user, and now I look..."
Your users view messageList, but they write their items to moderationList. Your Java server code monitors this list, validates the item and then adds the item to messageList. This is a common queue pattern that we use a lot internally at Firebase.
At the current moment, I am trying to understand how to add any data to GA. I read the data from my GA account using Core Reporting API and Managment API without any problems. But now I want to add the data (the number of phone calls) to GA account programmatically. Somebody can explain me step by step - how can I do this?
The Measurement Protocol is how we send data to Google Analytics. The JavaScript snippet that we use in our websites also uses the Measurement protocol as do the SDK's for Android and IOS. Unfortunately there is no (official) SDKs for the other languages like Java for instance.
That being said you can technically code it yourself in any language that can handle a HTTP get or a HTTP post. I have personally done it for C#.
POST /collect HTTP/1.1
Host: www.google-analytics.com
payload_data
The following parameters are required for each payload:
v=1 // Version.
&tid=UA-XXXXX-Y // Tracking ID / Property ID.
&cid=555 // Anonymous Client ID.
&t= // Hit Type.
A few tips to get you started.
Check out validating hits this is very useful in the beginning for debugging your requests.
some of the parameters are only valid for certain hit types. Make sure you check the documentation.
Cid is just a string it can be anything most people send a Guid its basically used by the server to identify a unique session.
if you are doing this for an application google analytics account remember to send screenview not pageview the same goes for web application.
check the realtime report on google analytics to see if your hits are getting recorded.
Update for question in comment:
I recommend while you are getting the idea of this you start with just using HTTP GET in a web browser. Its easer to test your requests against debug that way. For example put this in a browser.
https://google-analytics.com/debug/collect?v=1&tid=UA-123456-1&cid=5555&t=pageview&dp=%2FpageA
DP is document path and I am not sure why it is requiring that you send that.
ScreenView hit type VS PageView hit type.
There are two types of Google Analytics accounts ones for applications like android applications or sometimes web applications, and web sites. Application Google analytics accounts are meant to be used with ScreenView hit (the user checks a screen in the application) type and web accounts use PageViews (the user views a webpage). If you send a Pageview to an application Google Analytics account it will accept the hit but there will be no way for you to see the data. If you send a ScreenView to a web Google Analytics account it will again accept the data but you wont see it.
I am developing Android Application for Chat between two users as private session.
Android application would be Android 2.0 and above . If any user wants to chat then he can enter any email to chat and session between two users will be private and can able to store in database.
Other user should not be able to watch the private sesion.
if any one answer about android application where it will be connected to web server (php) then good for me to understand .
So if any one known the develpoment flow please suggest here .
Please don't suggest about IRC Chat where all user combined in same open template.
You could use an XMPP server and use for instance asmack library for android.
Tutorials about the android application: http://davanum.wordpress.com/2007/12/31/android-just-use-smack-api-for-xmpp/
There are several different servers out there. For instance OpenFire. http://www.igniterealtime.org/projects/openfire/
If sounds like what you want is an XMPP server with client to client encryption.
Here are a list of XMPP server options: http://xmpp.org/xmpp-software/servers/
Here is a discussion on various XMPP libraries to use with Android: Android and XMPP: Currently available solutions
As for the encryption, it looks like you want to mimic what OTR does (for pidgin). The description of how the protocol works is posted here: http://www.cypherpunks.ca/otr/Protocol-v2-3.1.0.html
You can also grab their source code from here: http://www.cypherpunks.ca/otr/index.php#downloads (warning: code is written in C)
This is link for Chat application for Android for private session and best suitable for users who want to use web with android . where any user can be signup or signin then get friends list with access of database to android and easily send messages to friends in a private session can chat unlimted . this feature more include like sending request and accepting/rejecting request .
You can do this in node.js very easily and if you need already implemented code then you can use this https://github.com/heroic/node-private-chat.
If you find it insufficient then you can easily extend it with very minimal efforts and don't use php for it. It isn't design for these type of work. Node is best suitable for it. Just run above code and connect to it with your android application.
Best
Deepak
I am looking for a way to validate the DKIM signature of the incoming email.
I know how to do it in Java SE but it will use classes like javax.naming.directory.DirContext to get data from DNS server and this class is not white listed in App Engine.
Any idea how to communicate with DNS form Google App engine?
There is a blog post that says:
Once you've configured DKIM, just send
an email from your Google Apps account
to:
dkim#dkim-test.appspotmail.com
within minutes, you should get back an
email that says "PASS" or "FAIL". If
your test passed, you're all set!
I tried it and it works!
It seems like a Google App Engine Application. How is it done?!
I'm the author of the dkim-test app. Unfortunately I did not actually find a native way to do DNS queries in AppEngine. There's a feature request in the AppEngine issues tracker here:
http://code.google.com/p/googleappengine/issues/detail?id=354
The way I got around this for dkim-test was to do a HTTP GET request to http://whatsmyip.us/dns_txt.php?host=google.com (where google.com is the host I want to retrieve TXT records for).
Obviously there are some down sides here. dkim-test is entirely dependent on whatsmyip.us to work, should that service go down or they decide to block dkim-test, then it would break. Things would also break if they changed the format of the response.