开发者

Call an URL without opening a browser window

开发者 https://www.devze.com 2023-03-15 18:01 出处:网络
I have an aplication wich I use to register some items. I want to store thoose at an online database, for that matter I created a simple php page that receives the variables via URL and adds them to a

I have an aplication wich I use to register some items. I want to store thoose at an online database, for that matter I created a simple php page that receives the variables via URL and adds them to a database. I can get things working swiftly by calling the browser intent and opening the URL, but thats kind of boring. Is there any other way to call my URL without opening the browser and st开发者_如何学Goill run the php code?


It would be a web service call, see this thread... How to call a SOAP web service on Android

Technically, any time you call a web url to do something (ex: a simple php page that receives the variables via URL and adds them to a database) its a web service. Now in your case its likely it does not use SOAP and have a WSDL, but its more of a RESTful type setup, in which you post the data and it processes it.

HttpClient httpClient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
HttpGet httpGet = new HttpGet("http://www.example.com/" + URL);
response = httpClient.execute(httpGet, localContext);


Yes, you could do it by choosing any one of following options among multiple options available. All below option will mock browser behavior and eventually execute call your PHP service.

  1. Use curl utility for your operating system and
  2. Use POSTMAN utility, and call the your code by just submitting the request.
  3. Write a client code in your favorite language that will mock your browsers call.
  4. Write a shell script or windows batch file that eventually call any of above.
0

精彩评论

暂无评论...
验证码 换一张
取 消