运行我的单元测试我发现在android上我没有收到完整的原子文档,而代码适用于JSE。
网址为:https://www.googleapis.com/buzz/v1/activities/@me/@consumption?max-results=25
请求标头是: 授权:[OAuth oauth_token =“validToken”,oauth_consumer_key =“anonymous”,oauth_version =“1.0”,oauth_signature_method =“HMAC-SHA1”,oauth_timestamp =“1282297108”,oauth_nonce =“5247048527864989575”,oauth_signature =“validSignature”]
发出HTTP请求的代码
public static String send( HttpsURLConnection request )
throws BuzzIOException
{
StringBuffer response = null;
try
{
// Send request
request.connect();
// Read response
InputStream is = request.getInputStream();
response = new StringBuffer();
byte[] b = new byte[4096];
for ( int n; ( n = is.read( b ) ) != -1; )
{
response.append( new String( b, 0, n ) );
}
}
catch ( Exception e )
{
throw new BuzzIOException( e );
}
//TODO remove debug line, i could set log4j but it is not compatible with android
try{
Class<?> clazz = Class.forName("android.util.Log");
Method androidLog = clazz.getMethod("d", new Class[]{String.class,String.class});
androidLog.invoke(null, "BuzzIO",response.toString());
} catch (Exception e) {
System.out.println(response.toString());
}
return response.toString();
}
我收到的回复是无效的原子Feed,因为它被截断了。预期的长度大约是86043个字符,但我得到的回复只有4435