Created
January 24, 2010 23:10
-
-
Save superfeedr/285504 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
List<String> hubUrls = new ArrayList<String>(); | |
hubUrls.add(urlMapping.getUserUrls(dot.getAuthor()).getRecentAtomFeedUrl().toString()); | |
hubUrls.add(urlMapping.getUserUrls(dot.getAuthor()).getHomeAtomFeedUrl().toString()); | |
hubUrls.add(urlMapping.getUserUrls(dot.getAuthor()).getCreatedAtomFeedUrl().toString()); | |
hubUrls.add(urlMapping.getDotUrls(dot).getAtomFeed().toString()); | |
for (User user : userFollowDao.getFollowers(dot.getAuthor())) { | |
hubUrls.add(urlMapping.getUserUrls(user).getHomeAtomFeedUrl().toString()); | |
} | |
StringBuilder body = new StringBuilder("hub.mode=publish"); | |
for (String hubUrl : hubUrls) { | |
body.append("&hub.url=").append(URLEncoder.encode(hubUrl, "UTF8")); | |
} | |
URL url = new URL(PUBSUBHUBBUB_HUB); | |
HttpURLConnection conn = (HttpURLConnection) url.openConnection(); | |
conn.setDoOutput(true); | |
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream(), "UTF8"); | |
try { | |
wr.write(body.toString()); | |
wr.flush(); | |
String responseBody = getResponseBody(conn); | |
boolean success = conn.getResponseCode() == 204; | |
// ... process response | |
} finally { | |
wr.close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment