Using URLFetchService / URL - Google appengine for java
I'm using URL Fetch Java API http://code.google.com/appengine/docs/java/urlfetch/overview.html#Fet... to get information from graph.facebook.com, however, i keep getting the error: java.lang.IllegalArgumentException at java.net.开发者_开发技巧URI.create(URI.java:842) ... Caused by: java.net.URISyntaxException: Illegal character in query at index 58: https://graph.facebook.com/me?access_token=... Any idea?
The error message pretty much says it all: the URI you are attempting to fetch contains an illegal character at index 58. I also get the exception with your URL:
public static void main(String[] args) throws Exception {
String s = "https://graph.facebook.com/me?access_token=593172238640599|e2a5e8bb8625b56358fe6219.1-530295086|zt7TYKmSF4e3WLWbF8jc7_P8MK8";
URI uri = new URI(s);
}
throws:
Exception in thread "main" java.net.URISyntaxException: Illegal character in query at index 58: https://graph.facebook.com/me?access_token=593172238640599|e2a5e8bb8625b56358fe6219.1-530295086|zt7TYKmSF4e3WLWbF8jc7_P8MK8 at java.net.URI$Parser.fail(URI.java:2809) at java.net.URI$Parser.checkChars(URI.java:2982) at java.net.URI$Parser.parseHierarchical(URI.java:3072) at java.net.URI$Parser.parse(URI.java:3014) at java.net.URI.(URI.java:578)
The character at position 58 is the "|" character. You need to URL encode this character (and its other occurances).
精彩评论