【发布时间】:2014-05-14 19:21:03
【问题描述】:
您好,我尝试从千禧年媒体发出 GET 请求,以在我的黑莓 Java 应用程序中显示广告,但我似乎无法让它工作。这就是我所拥有的
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 网站获得的信息
【问题讨论】:
-
我认为您需要查看您链接到的规范,并确保您按照 API 要求的方式提供了所有信息。据我所知,你不是。下次,当您报告此类问题时,您能否准确描述您在此过程中的进度以及您收到的错误代码或信息。最后,我怀疑你会直接从他们那里得到更好的支持,这里是你需要的 URL。 tools.mmedia.com/user/supportDevPortal
标签: blackberry get advertisement-server