好吧,我正试图找到一种方法让http组件跟随重定向,但没有在谷歌上找到任何,所以我来这里寻求帮助该功能:
public String GetSite(String site, String path) throws Exception {
HttpParams params = new SyncBasicHttpParams();
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(params, "UTF-8");
HttpProtocolParams.setUserAgent(params, "HttpComponents/1.1");
HttpProtocolParams.setUseExpectContinue(params, true);
HttpProcessor httpproc = new ImmutableHttpProcessor(new HttpRequestInterceptor[]{
// Required protocol interceptors
new RequestContent(),
new RequestTargetHost(),
// Recommended protocol interceptors
new RequestConnControl(),
new RequestUserAgent(),
new RequestExpectContinue()});
HttpRequestExecutor httpexecutor = new HttpRequestExecutor();
HttpContext context = new BasicHttpContext(null);
HttpHost host = new HttpHost(site, 80);
DefaultHttpClientConnection conn = new DefaultHttpClientConnection();
ConnectionReuseStrategy connStrategy = new DefaultConnectionReuseStrategy();
context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, host);
try {
String[] …Run Code Online (Sandbox Code Playgroud) 好吧,我现在已经尝试了3个小时了.使用大量的api它仍然无法正常工作.
我正在尝试解析
{
"id": 8029390,
"uid": "fdABNhroHsr0",
"user": {
"username": "Skrillex",
"permalink": "skrillex"
},
"uri": "/skrillex/cat-rats",
"duration": 305042,
"token": "VgA2a",
"name": "cat-rats",
"title": "CAT RATS",
"commentable": true,
"revealComments": true,
"commentUri": "/skrillex/cat-rats/comments/",
"streamUrl": "http://media.soundcloud.com/stream/fdABNhroHsr0?stream_token=VgA2a",
"waveformUrl": "http://w1.sndcdn.com/fdABNhroHsr0_m.png",
"propertiesUri": "/skrillex/cat-rats/properties/",
"statusUri": "/transcodings/fdABNhroHsr0",
"replacingUid": null,
"preprocessingReady": null
}
Run Code Online (Sandbox Code Playgroud)
在数组/列表中.有帮助吗?