I am making an desktop javafx application for school which work online server communication via json and php. I want to send a image file taken form java application to php server
You can make use of a http library like unirest to make your http request. sending images will be in the form
Unirest.post('URL_TO_POST_TO')
.header("accept", "application/json")
.field("image", new File(pathToImage))
.asJson();
Related
I have a website that generates different JSON that need to be used in the future request.
The request could be done by CURL but I'll use the Advanced Rest Client to send the request.
The website is in PHP.
Advanced REST Client is a pluggin of Chrome.
Do you know how I could generate my request in the REST Client from the website without copy and paste the JSON code?
I've tried by curl but it doesn't work.
The json used in the REST client is working
Just need to make a tunnel between the website and the REST Client with any JSON file
Do you know how I could generate my request in the REST Client from the website
You can't.
Advanced REST Client is primarily a debugging tool. It isn't designed to be used by websites.
If you want to make an HTTP request to a RESTful web service from a website then either:
Write client-side code in JavaScript that uses fetch, XMLHttpRequest or a library that wraps one of them such as axios or
Write server-side code in your server-side language of choice and generate whole HTML pages on demand.
My question is, how can I send a data (for example a text box) from a web mobile app (cordova) to my own server and save that data in server?
I tried post method but I couldn't run it completely.
You have to use AJAX request to make post requests to the PHP server.
You can find a documentation Ajax request using pure Javascript here.
Or using Jquery Ajax API
Watch out for CROS and Acces Control if you are not in localhost.
Setup on my server is a set of PHP scripts which when run will interface with a MySQL database and return information in the form of a HTML response. I want my android application to be able to 'navigate' to one of these pages and post/get the information required for validation and the query, and then get a response.
I cant find out how to get the HTML response information from a browser or find any other method to do this communication. I cannot connect directly with the SQL database as the php scripts are the interface for an application and website also and I want to connect all platforms through the php scripts.
Does anyone know of a means by which I can communicate with the PHP server and read the response details?
Delphi ships with Indy preinstalled. Indy works on mobile platforms, including Android. You can use Indy's TIdHTTP component to send HTTP GET and POST requests to your webserver as needed. Response data can be given to you as either a String (which TIdHTTP will decode to UTF-16 for you) or a TStream (raw data).
I am trying to write a Sencha Touch application that I can package in PhoneGap for iOS, Android etc...
The app allows you to input some data which I would like to save to my backend server using PHP/MySQL. It all works when I use an AJAX proxy as I am testing the app on the same server as my database.
However when I package it for mobile devices I run into the same-domain restrictions of AJAX calls. So I modified it to use the JSONP proxy and I can read the data from the server database but have no idea how to write records back. Do I need to somehow pass the data in the GET request? Obviously the server side PHP needs to be different because of the callbacks and the fact JSONP is forced to used GET requests. I am also trying to get CORS working but currently no success.
So my question is how would I implement writing data back to my backend server from a packaged mobile Sencha app running on a mobile device? Either using JSONP if that is even possible or any other alternatives are welcome?
Many Thanks…
I am working with Android 2.2. I currently have the application wrapped in phonegap with Sencha. I have forms that use an Ajax request to post the information and send it to an email. It all works fine before I wrap it in Phonegap. I have read that you cannot do Ajax requests through phonegap though. Is there any way I can get this to work?
You can do AJAX requests through a Phonegap app. I have an app running on both Android and iPhone and it works fine for both local (in app) and remote (mobile to server) communications. I use jQuery, but I don't suspect that what library I use matters.