0

I'm creating Java program for payments.

For example I have to send message "FOO.BAR" to number 123123 then I will receive message from this number with code, for example XYZXYZ

Now I've got an API from my hosting, something like a

html://foo.bar/msg.php?received_code="MY_RECEIVED_CODE"

so MY_RECEIVED_CODE will be XYZXYZ

html://foo.bar/msg.php?received_code="XYZXYZ"

And we will receive a reply from this link with message in single number:

  • 0 - Means that we typed wrong reply code
  • 1 - Means that everything is okey and it's done
  • 2 - Means that we haven't put any code inside our received_code=""

And now how to execute this link and handle answer in Java?

Something like:

void payment(String code)
{
    int answer = executeLink("http://foo.bar/...received_code=" + code + "\"");

    if(answer == 0)...
    if(answer == 1)...
}
0

1 Answer 1

1

You want to use a REST client, as for example described in:

http://crunchify.com/how-to-create-restful-java-client-using-apache-httpclient-example/

Essentially using the Apache's HttpClient.

HttpClient

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.