Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
rahuldeshpande committed Jun 11, 2015
1 parent bdc6a56 commit f19c6e9
Showing 1 changed file with 42 additions and 29 deletions.
71 changes: 42 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,48 @@ NSURL *url= [NSURL URLWithString:@"http://arcane-ridge-6454.herokuapp.com/charge
```
* Or in Android:
```java
String data = "your data";
String response;

URL url = new URL("http://arcane-ridge-6454.herokuapp.com/charge.php");
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
try {
urlConnection.setDoOutput(true);
urlConnection.setChunkedStreamingMode(0);

OutputStream out = new BufferedOutputStream(urlConnection.getOutputStream());
out.write(data.getBytes("UTF-8"));
out.close();

urlConnection.connect();

InputStream in = new BufferedInputStream(urlConnection.getInputStream());
StringBuilder sb = new StringBuilder();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
String line = "";
while ((line = rd.readLine()) != null) {
sb.append(line);
}
in.close();

response = sb.toString();
}
finally {
urlConnection.disconnect();
}
URL url = null;
HttpURLConnection con = null;
try {
URL url = new URL("http://simplifypay.herokuapp.com//charge.php");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
//add reuqest header
con.setRequestMethod("POST");
con.setRequestProperty("User-Agent", ""Mozilla/5.0");
con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
String urlParameters = "simplifyToken="+token.getId()+"&amount=1000";
// Send post request
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
wr.writeBytes(urlParameters);
wr.flush();
wr.close();
int responseCode = con.getResponseCode();
System.out.println("\nSending 'POST' request to URL : " + url);
System.out.println("Post parameters : " + urlParameters);
System.out.println("Response Code : " + responseCode);
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
//print result
System.out.println(response.toString());
//
} catch (Exception e) {
e.printStackTrace();
} finally {
con.close();
}
```
##References
Expand Down

1 comment on commit f19c6e9

@eclipse1973
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

provided

Please sign in to comment.