import java.io.IOException;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.PostMethod;
public class PushCall {
public static void main(String[] args) {
String accountCode = "xxxxx";
String voiceCode = "xxx";
String mobileNo = "xxxx";
String a = callApi(accountCode, voiceCode, mobileNo);
System.out.println(a);
}
public static String callApi(String accountCode,String voiceCode,String mobileNo) {
String returnCode="";
int re = 0;
HttpClient client = new HttpClient();
String url1 ="https://services.mgov.gov.in/PushCallAPI/FeedBackCalling";
PostMethod method = new PostMethod(url1);
method.addParameter(new NameValuePair("username",accountCode));
method.addParameter(new NameValuePair("MobileNo", mobileNo));
method.addParameter(new NameValuePair("voiceCode", voiceCode));
try {
client.executeMethod(method);
String a = method.getResponseBodyAsString();
if(a.contains("Submitted Successfully")) {
re = 1;
}
System.out.println("OUTPUT a :: "+a);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(re==1){
returnCode="SUCCESS";
}else{
returnCode="FAIL";
}
return returnCode;
}
|