We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, I've never coded anything like this before so I'm really not sure of where/how to start.
I'm looking to write something which will communicate with this website, upload an image and then download the generated text response. There is currently no official API to do this.
I managed to speak with someone who has done this before and he said that he achieved this through sending headers to the url.php file and parsing the response, but due to my limited understanding of html & php I'm really not sure how this would translate into code. If someone could explain in more detail, write up some pseudo-code or point me in the direction of useful things to look at to expand my understanding of the topic I'd be super appreciative.
Thanks a lot!
Processing 2.2.1 Windows 8
Answers
Processing.js most likely won't let you- posting across domains doesn't work in JavaScript.
There are Java classes that might help. Look into the HttpUrlConnection class.
KevinWorkman, I don't think the OP mentioned Processing.js.
rossdickinson, this has been done with the Client class in the Network library shipped with Processing, I think. Try and search from the main site.
@PhiLho I had a look over some of the Client class documentation yesterday, but I'm really not sure how to work with it. I know the first step of the program would be to upload an image to the website to be analysed, but I'm not sure how to do this with the documentation I've read from within the class. Would I need to extract html information from the website upload button manually and write() something to it? if so do you have any suggestions on how I can do this? Thanks a lot for replying!
@PhiLho He didn't mention any particular version of Processing. I just think it's important to be open about any limitations a possible solution introduces. Relying on a Java class means you won't be able to deploy as a web application. That might not be a big deal, but it should at least be mentioned.
Since this is "How-To" category, it's assumed that's "Java Mode" related. Although w/o any 3rd libraries.
JavaScript Mode (PJS) goes to "Question about Modes -> JavaScript Mode" category.
i might be more confused now than i was before i posted the question, haha. i didn't specify the mode as i have not written any code yet cause i have no idea where to start. everything else i've written has been in java mode though so this will probably be written in java mode too if someone could help me out at all? :) thanks you guys
Where does it say that?
However, all of this is a moot point: if you don't care about JavaScript mode, then don't worry about it. It's just something to be aware of.