Created
January 14, 2010 16:43
-
-
Save shin1ogawa/277305 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static final String BASEURL = "https://www.instapaper.com/api/"; | |
static int addToInstaPaper(String username, String password, String url) throws IOException { | |
StringBuilder b = new StringBuilder(); | |
b.append("username=").append(URLEncoder.encode(username, "utf-8")); | |
b.append("&password=").append(URLEncoder.encode(password, "utf-8")); | |
b.append("&url=").append(URLEncoder.encode(url, "utf-8")); | |
b.append("&auto-title=1"); | |
byte[] payload = b.toString().getBytes("utf-8"); | |
URL apiUrl = new URL(BASEURL + "add"); | |
HttpURLConnection connection = (HttpURLConnection) apiUrl.openConnection(); | |
connection.setDoOutput(true); | |
connection.setRequestMethod("POST"); | |
OutputStream os = connection.getOutputStream(); | |
os.write(payload); | |
os.close(); | |
return connection.getResponseCode(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment