2014-04-28 36 views
0

您好,我試圖從千禧媒體做廣告的GET請求在我的黑莓Java應用程序中顯示,但我似乎無法讓它工作。這是我有什麼來自Millennial Media Ad服務器的GET請求

HttpConnection conn = null;    
InputStream in = null;    
StringBuffer buff = new StringBuffer();    
String result = ""; 

String url ="http://ads.mydas.mobi/getAdapid=157899&auid=ddd25abbb993f79454b12827c803fbafab2ad89b&ua";       try {     
conn = (HttpConnection) new ConnectionFactory().getConnection(url).getConnection(); conn.setRequestMethod(HttpConnection.GET);     
conn.setRequestProperty("User-Agent",    
"Profile/MIDP-1.0 Confirguration/CLDC-1.0");     
if (conn.getResponseCode() == HttpConnection.HTTP_OK) {      
in = conn.openInputStream();      
// parser.parse(in, handler);     
buff.append(IOUtilities.streamToBytes(in));      
result = buff.toString();     
} else {      
result = "Error in connection" + conn.getResponseCode(); 
((SettingWaitScreen)screen).update(result);    
} catch (Exception ex) {     
ex.printStackTrace();    
} finally {     
try {      
if (in != null) {       
in.close();      
}      
conn.close();     
} catch (IOException e) {      
e.printStackTrace();     
}    
} 

我不知道這是否是正確的方法任何幫助做這個廣告請求是高度讚賞。這是我從網站上得到的http://docs.millennialmedia.com/S2S/ad-request.html

+1

我認爲你需要檢查你鏈接的規範,並確保你提供API調用所需的所有信息。據我所知,你不是。在下一次,當你報告這樣的問題時,你能否描述一下你得到的程序到底有多遠,以及你收到的錯誤代碼或信息。最後,我懷疑你會直接從他們那裏得到更好的支持,這裏是你需要的URL。 https://tools.mmedia.com/user/supportDevPortal –

回答