use of com.xrtb.pojo.BidRequest in project XRTB by benmfaul.
the class ReadInspectorLog method main.
public static void main(String[] args) throws Exception {
BufferedReader br = null;
br = new BufferedReader(new FileReader("/home/ben/bin/testdata"));
String data = null;
HttpPostGet hp = new HttpPostGet();
while ((data = br.readLine()) != null) {
data = data.replace("GOOD, DATA: ", "");
BidRequest r = new BidRequest(new StringBuilder(data));
}
}
use of com.xrtb.pojo.BidRequest in project XRTB by benmfaul.
the class Creative method createSample.
/**
* Creates a sample of the ADM field, useful for testing your ad markup to
* make sure it works.
*
* @param camp
* Campaign. The campaign to use with this creative.
* @return String. The ad markup HTML.
*/
public String createSample(Campaign camp) {
BidRequest request = new Nexage();
String page = null;
String str = null;
File temp = null;
Impression imp = new Impression();
imp.w = 666;
imp.h = 666;
BidResponse br = null;
try {
if (this.isVideo()) {
br = new BidResponse(request, imp, camp, this, "123", 1.0, null, 0);
imp.video = new Video();
imp.video.linearity = this.videoLinearity;
imp.video.protocol.add(this.videoProtocol);
imp.video.maxduration = this.videoDuration + 1;
imp.video.minduration = this.videoDuration - 1;
str = br.getAdmAsString();
/**
* Read in the stubbed video page and patch the VAST into it
*/
page = new String(Files.readAllBytes(Paths.get("web/videostub.html")), StandardCharsets.UTF_8);
page = page.replaceAll("___VIDEO___", "http://localhost:8080/vast/onion270.xml");
} else if (this.isNative()) {
// br = new BidResponse(request, camp, this,"123",0);
// request.nativead = true;
// request.nativePart = new NativePart();
// str = br.getAdmAsString();
page = "<html><title>Test Creative</title><body><img src='images/under-construction.gif'></img></body></html>";
} else {
br = new BidResponse(request, imp, camp, this, "123", 1.0, null, 0);
str = br.getAdmAsString();
page = "<html><title>Test Creative</title><body><xmp>" + str + "</xmp>" + str + "</body></html>";
}
page = page.replaceAll("\\{AUCTION_PRICE\\}", "0.2");
page = page.replaceAll("\\$", "");
temp = File.createTempFile("test", ".html", new File("www/temp"));
temp.deleteOnExit();
Files.write(Paths.get(temp.getAbsolutePath()), page.getBytes());
} catch (Exception error) {
error.printStackTrace();
}
return "temp/" + temp.getName();
}
use of com.xrtb.pojo.BidRequest in project XRTB by benmfaul.
the class AnylzeForensiq method main.
public static void main(String[] args) throws Exception {
forensiq = ForensiqClient.build("6RLzOXoxntkqr0PHJ1Z0");
String content = null;
String source = "../request.json";
BidRequest br = null;
FileReader fr = new FileReader(source);
BufferedReader bufr = new BufferedReader(fr);
double count = 0;
double frauds = 0;
double errored = 0;
while ((content = bufr.readLine()) != null && count < 1000) {
count++;
StringBuilder sb = new StringBuilder(content);
try {
br = new BidRequest(sb);
if (br.fraudRecord != null) {
frauds++;
System.out.println(content);
Map map = mapper.readValue(content, Map.class);
List imp = (List) map.get("imp");
Map x = (Map) imp.get(0);
Map device = (Map) map.get("device");
if (device != null) {
String ip = (String) device.get("ip");
Integer counts = ips.get(ip);
if (counts == null) {
counts = new Integer(0);
}
counts++;
ips.put(ip, counts);
}
Map site = (Map) map.get("site");
if (site != null) {
String name = (String) site.get("name");
Integer counts = names.get(name);
if (counts == null) {
counts = new Integer(0);
}
counts++;
names.put(name, counts);
}
}
System.out.println(count);
} catch (Exception error) {
errored++;
}
}
System.out.println("Total = " + count + ", Errored = " + errored + ", Fraud = " + frauds + " (" + (frauds / count * 100.0) + ")");
System.out.println("\n\nIP analysis\n\n");
List<Tuple> tups = RequestScanner.reduce(ips, (int) (count - errored));
tups.forEach((q) -> System.out.printf("%s, %d, (%.3f%%)\n", q.site, q.count, q.percent));
System.out.println("\n\nSite analysis\n\n");
tups = RequestScanner.reduce(names, (int) (count - errored));
tups.forEach((q) -> System.out.printf("%s, %d, (%.3f%%)\n", q.site, q.count, q.percent));
}
use of com.xrtb.pojo.BidRequest in project XRTB by benmfaul.
the class Cognos method indexRequests.
public static void indexRequests(List<String> list, Map<String, BidRequest> map, String file) throws Exception {
BufferedReader br = new BufferedReader(new FileReader(file));
int k = 0;
for (String line; (line = br.readLine()) != null; ) {
if (line.contains("\0")) {
System.out.println(line);
} else {
// System.out.println(line);
try {
BidRequest bidr = new BidRequest(new StringBuilder(line));
if (list.contains(bidr.id)) {
map.put(bidr.id, bidr);
k++;
}
} catch (Exception error) {
//System.out.println(error);
}
}
}
System.out.println("Number of requests indexed: " + k);
}
use of com.xrtb.pojo.BidRequest in project XRTB by benmfaul.
the class Cognos method main.
public static void main(String[] args) throws Exception {
mapper.setSerializationInclusion(Include.NON_NULL);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
Map<String, BidRequest> requests = new HashMap();
List<String> bidids = gatherBidIds("/home/ben/bin/dumplog/bids");
indexRequests(bidids, requests, "/home/ben/bin/dumplog/request");
for (String bid : bidids) {
BidRequest r = requests.get(bid);
if (r != null) {
Object ob = r.interrogate("site.publisher.id");
if (ob == null) {
ob = r.interrogate("app.publisher.id");
}
if (ob != null) {
JsonNode node = (JsonNode) ob;
String value = node.asText();
if (value.equals("130003498") || value.equals("130054054"))
System.out.println("--------------\nBad ID: " + r.id + "\n" + r.toString());
}
ob = r.interrogate("device.os");
if (ob != null) {
JsonNode node = (JsonNode) ob;
String value = node.asText();
if (value.equalsIgnoreCase("iOS") == false) {
System.out.println("--------------\nBad OS: " + r.id + "\n" + r.toString());
}
}
}
}
}
Aggregations