Created
September 22, 2010 12:34
-
-
Save anarcher/591584 to your computer and use it in GitHub Desktop.
google app engine URLFetch scala example
This file contains 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
import com.google.appengine.api.urlfetch._ | |
import java.net.URL | |
import java.net.URLEncoder | |
val urlFetch = URLFetchServiceFactory.getURLFetchService() | |
val url = new URL("http://me2day.net/api/get_posts/anarch.json") | |
val req = new HTTPRequest(url,HTTPMethod.GET) | |
val params = Map("scope" -> "all") | |
val qs = Map(params : _* ).foldLeft("")((qs,p) => { (if(qs != "") qs+"&" else qs)+"%s=%s".format(p._1,p._2) }) | |
req.setPayload(qs.getBytes) | |
val res = urlFetch.fetch(req) | |
val content = new String(res.getContent) | |
//ref: http://groups.google.com/group/google-appengine/browse_thread/thread/2ce349fd030cef48 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment