How to get URL in Java using the Remember The Milk API? - java

I want to write an Android application that uses the Remember the Milk API, but I can't figure out how to use the API's app authentication scheme. How do I generate the URL to authenticate my application with RTM?

I was looking for this too, and seems it was right in front of me. https://www.rememberthemilk.com/services/api/request.rest.rtm is where it explains the format.
Basically it's https://api.rememberthemilk.com/services/rest/ and then whatever you want to send.
So it would seem you'd start by getting the frob using https://api.rememberthemilk.com/services/rest/?method=rtm.auth.getFrob&api_key=123456789
Then when you get the frob back you'd use it to get a token with https://api.rememberthemilk.com/services/rest/?method=rtm.auth.getToken&api_key=123456789&frob=0a56717c3561e53584f292bb7081a533c197270c
Of course you'd replace that random key and frob with your actual key and whatever you get back from getFrob.
I'm about to try using this myself, so I'll try and post back if anything needs to be changed.

Related

How to handle emoji in java and save into database, Then display on UI

I am sending a request on third party api. and a getting response like ⌚ Test which is actually looks like ⌚ Test on third party UI. My question is. In which format emoji's i should save into database , and how i can display the same emoji on UI as well.
please help
For this you will need to find the correct encoding to store your string in your database.
Since I don't know which DB you're using, you can go trough this tutorial to understand how to define your column in DB to store the correct format. EXAMPLE

Java XML Signature API and Smart Card

I'm prototyping on how to sign XML documents with the Java XML Signature API and I have it working fine when working with a private key from a local keystore but I'm looking for some assistance in how to reach my ultimate goal:
How/where to extend the JSR-105 implementation so that I could sign the XML document with a Smart Card reader (where the private key resides behind a PIN code)? The https://docs.oracle.com/javase/8/docs/technotes/guides/security/xmldsig/overview.html indicates that it should be possible.
The implementation I'm working with essentially runs a REST interface on the localhost where you POST the job in JSON format in order to sign stuff. I'm looking for a way to hook in the signing step so that the Java API basic implementation does the c14n stuff and digests the references and passes "the right stuff" to my implementation for a REST-roundtrip to the card service and then (if the PIN is correct), signs the data and I extract the result and pass it back in order for the Java API to take over and insert the signature in the correct location in the document.
If anyone has done something like this, I would appreciate pointers instead of my having to create decorators for everything and trying to breakpoint myself through the entire reference implementation.
Thanks in advance,
Nik

Combine two http responses into one

Is it possible to send extra data attached to a http response via Java or Php?
My Website is a homework-platform: One User enters homeworks into a database, and all users can then see the homeworks on the website. The current load is very inefficient, as the browser makes two requests for eveything to load: One for the index file and one for the homeworks. For the homeworks request the client also sends settings of the user to the server, based on which the returned homeworks are generated by a Php script.
Now, I wonder, if it is possible, to combine those two requests into one? Is it maybe possible to detect the http request with Java or Php on the server, read the cookies (where the settings are saved), then get the homeworks from the database and send the data attached to the http response to the client? Or, even better, firstly only return the index file and as soon as possible and the homework data afterwards as a second response, because the client needs some time to parse the Html & build the DOM-tree when it can't show the homeworks anyway.
While browsing the web I stumbled across terms like "Server-side rendering" and "SPDY", but I don't know if those are the right starting points.
Any help is highly appreciated, as I'm personally very interested in a solution and it would greatly improve the load time of my website.
A simple solution to your problem is to initialize your data in the index file.
You would create a javascript object, and embed it right into the html, rendered by your server. You could place this object in the global namespace (such as under window.initData), so that it can be accessed by the code in your script.
<scipt>
window.initData = {
someVariable: 23,
}; // you could use json_encode if you use php, or Jackson if you use java
</script>
However, it is not a huge problem if your data is fetched in a separate server request. Especially when it takes more time to retrieve the data from the database/web services, you can provide better user experience by first fetching the static content very quickly and displaying a spinner while the (slower) data is being loaded.

Persisting XML parsed object

I am using an xml parser to parse the login response from a request to a server. The xml content returns me sensitive data that uniquely identifies a client so i can fetch more details about the client in other part of my app later on.
In iOS, i would just create an object from the parsed values to hold the clientAuthenticationDetails and access it from anywhere else in the app using the appDelegate instance.
Is there a way for me to do the same in Android? I have read up on SharedPreferences but i am not sure if that is how others implement this sort of functionality or how secure it is since i do have sensitive client data in the response.
The easy option is to use Shared Preferences and write up some sort of method that will encrypt/decrypt the values in the preferences. Usually something like a DES encoder/decoder. you can find samples of using cypher anywhere.
The Harder option which usually doesn't make sense to implement is to store the account and credentials in the android AccountManager. I suggest going with the Shared Preferences option. Its enough in my opinion.

Multiple questions in Java (Validating URLs, adding applications to startup, etc.)

I have an application to build in Java, and I've got some questions to put.
Is there some way to know if one URL of a webpage is real? The user enters the URL and I have to test if it's real, or not.
How can I konw if one webpage has changes since one date, or what is the date of the last update?
In java how can I put an application running on pc boot, the application must run since the user turns on the computer.
I'm not sure what kind of application you want to build. I'll assume it's a desktop application. In order to check if a URL exists, you should make a HTTP HEAD Request, and parse the results. HEAD can be used to check if the page has been modified. In order for an application to start when the PC boots, you have to add a registry entry under Windows; this process is explained here
To check whether a url is valid you could try using a regular expression (regex for urls).
To know if a webpage has changed you can take a look at the http headers (reading http headers in java).
You can't make the program startup automatically on boot, the user must do that. However, you can write code to help the user set the program as startup app; this however depends on the operating system.
I'm not sure what you mean by "real". If you mean "valid", then you can just construct a java.net.URL from a String and catch the resulting MalformedURLException if it's not valid. If you mean that there's actually something there, you could issue an HTTP HEAD request like Geo says, or you could just retrieve the content. HTTPUnit is particularly handy for retrieving web content.
HTTP headers may indicate when the content has changed, as nan suggested above. If you don't want to count on that you can just retrieve the page and store it, or even better, store a hash of the page content. See DigestOutputStream for generating a hash. On a subsequent check for changes you would simply compare the new hash with the the one you stored last time.
Nan is right about start on boot. What OS are you targeting?

Categories