0

I am not familiar with Android Coding, I have to convert this code to PHP to get data from this API URL. Can you please help me to write this code in PHP?

public void onClick(View view) {
        ((InputMethodManager) InputData.this.getSystemService("input_method")).hideSoftInputFromWindow(view.getWindowToken(), 0);
        String charSequence = InputData.this.xyzView.getText().toString();
        String obj = InputData.this.inputOne.getText().toString();
        String obj2 = InputData.this.inputTwo.getText().toString();
        if (obj.equalsIgnoreCase("") || Integer.parseInt(obj) != 0) {
            if (obj2.equalsIgnoreCase("")) {
                obj2 = "0";
            }
            if (obj.equalsIgnoreCase("")) {
                InputData InputData = InputData.this;
                Toast.makeText(InputData, InputData.getString(R.string.err_msg_fileNo), 1).show();
                return;
            }
            InputData InputData2 = InputData.this;
            JSONObject jSONObject = new JSONObject();
            try {
                jSONObject.put("xyz", charSequence);
                jSONObject.put("inputOne", obj);
                jSONObject.put("inputTwo", obj2);
                jSONObject.put("reqFrom", "0123");
                jSONObject.put("password", "MjMEJJ6SXpj");
            } catch (JSONException e) {
                e.printStackTrace();
            }
            InputData2.URL = "https://apiurl.com/information/service/dataservide/";
            Log.d("ur;", InputData.this.URL);
            new C0328e(InputData.this, (C0324a) null).execute(new String[]{InputData.this.URL, jSONObject.toString()});
            return;
        }
        Toast.makeText(InputData.this, "Invalid Input", 1).show();

Also give suggestions if you have any. Thank you so much, Friends.

P K
  • 1
  • First, does the API have documentation? If so, start there. Second, you might not be familiar with Android coding, but if you are familiar with PHP or another language, I’d think this should be fairly easy to read the gist of [sending a JSON object to a URL](https://stackoverflow.com/a/6213693/231316). – Chris Haas May 28 '22 at 14:01
  • Hay, Thanks for sharing. Actually, there was no documentation, I found this from a live android app and they also haven't documented for this API, and the important part is they are fetching data with this method. Your suggested method should be help lets try. – P K May 29 '22 at 07:05

0 Answers0