自定义广告联盟接入解决方案,适用所有广告商接入。
一、著陸頁說明: 著陸頁及參數形式:http://www.xxx.cn/著陸頁?from=yrt&aop=1_1_0_1_1_1&tid=d000a26123454442dc4f3646922028e&lb1=1&lb2=2&lb3=3&lb4=4&lb5=5?? 。 任何一個頁面都可以當作著陸頁,
如:首頁著陸地址為:(http://www.xxx.cn?from=yrt&aop=1_1_0_1_1_1&tid=d000a26123454442dc4f3646922028e&lb1=1&lb2=2&lb3=3&lb4=4&lb5=5); 某專題頁著陸地址為:(http://www.xxx.cn/xxxx.html?from=yrt&aop=1_1_0_1_1_1&tid=d000a26123454442dc4f3646922028e&lb1=1&lb2=2&lb3=3&lb4=4&lb5=5)。
二、入參說明: ? ?? ? ??入參采用字母、數字、下劃線表示。不建議采用中文漢字。
? ? 1、from: 來源;能唯一區別某網站的字符串,用字母和數字表示,不能為空。 如:baidu、163、yrt等等 ? ? 2、aop:數據采集點定義;目前定義了六個采集點(如需要還可添加)。格式1_1_0_1_1_1,分別表示注冊_綁卡_充值_交易_提現_登錄;每個對應位上的值若為1表示開啟采集,為0表示關閉采集。如:某廣告商進來的用戶按注冊用戶及生產投資分成則該參數為:1_0_0_1_0_1。登錄位建議開啟 3、tid:第三方回調參數;若第三方需要回調作關聯則可傳此參數。一般在CPS上用到,如:武漢易瑞特的廣告平臺就需要用。 ? ? 4、lb1:終端類型;如:PC,WAP,APP等 ? ? 5、lb2:頻道或者專題類型;用以區別是同一網站的哪個地方來的。 ? ? 6、lb3:關鍵字識別代碼;如:1001對應著百度搜索關鍵字“P2P”,1002對應360搜索關鍵字“互聯網金融”,1003對應百度搜索關鍵字:“互聯網金融”等。 ? ? 7、lb4:預留加密串;針對特殊情況需要檢驗來源時和第三方約定。 ? ? 8、lb5:預留參數;該參數用于以后擴展。
在基類中獲取入參并存COOKIE
@After
?? ?protected static void getAdUnionParams(){ ??? ??? ?String from = params.get("from");
?? ??? ?if(from!=null){
?? ??? ??? ?Response.current().setCookie(Constants.ADUNION_CPACPS_FROM,from,null,"/",30*60*60*24,false);
?? ??? ??? ?String tid = params.get("tid");
?? ??? ??? ?String aop = params.get("aop");
?? ??? ??? ?if(tid!=null&&tid.length()>0){
?? ??? ? ?? ??? ?Response.current().setCookie(Constants.ADUNION_CPACPS_TID,tid,null,"/",30*60*60*24,false);
?? ??? ??? ?}
?? ??? ??? ?if(aop!=null)
?? ? ?? ??? ??? ?Response.current().setCookie(Constants.ADUNION_AOP,aop,null,"/",30*60*60*24,false);
?? ??? ??? ?
?? ??? ??? ?String retUrl = request.headers.get("referer")+"";
?? ??? ??? ?if(retUrl!=null&&!retUrl.equals("")&&!retUrl.equals("null"))
?? ??? ??? ??? ?Response.current().setCookie(Constants.COOKIE_KEY_BACKURL+"in",retUrl);
?? ??? ??? ?
?? ??? ??? ?String lb1 = params.get("lb1");
?? ??? ??? ?String lb2 = params.get("lb2");
?? ??? ??? ?String lb3 = params.get("lb3");
?? ??? ??? ?String lb4 = params.get("lb4");
?? ??? ??? ?String lb5 = params.get("lb5");
?? ??? ??? ?if(lb1!=null&&lb1.length()>0){
?? ??? ? ?? ??? ?Response.current().setCookie(Constants.ADUNION_AOP+"lb1",lb1,null,"/",30*60*60*24,false);
?? ??? ??? ?}
?? ??? ??? ?if(lb2!=null&&lb2.length()>0){
?? ??? ? ?? ??? ?Response.current().setCookie(Constants.ADUNION_AOP+"lb2",lb2,null,"/",30*60*60*24,false);
?? ??? ??? ?}
?? ??? ??? ?if(lb3!=null&&lb3.length()>0){
?? ??? ? ?? ??? ?Response.current().setCookie(Constants.ADUNION_AOP+"lb3",lb3,null,"/",30*60*60*24,false);
?? ??? ??? ?}
?? ??? ??? ?if(lb4!=null&&lb4.length()>0){
?? ??? ? ?? ??? ?Response.current().setCookie(Constants.ADUNION_AOP+"lb4",lb4,null,"/",30*60*60*24,false);
?? ??? ??? ?}
?? ??? ??? ?if(lb5!=null&&lb5.length()>0){
?? ??? ? ?? ??? ?Response.current().setCookie(Constants.ADUNION_AOP+"lb5",lb5,null,"/",30*60*60*24,false);
?? ??? ??? ?}
?? ??? ?}
?? ?}
SERVICE層中獲取參數并處理。
private static Cookie fromcookie; //來源
?? ?private static Cookie tidcookie;//第三方來參
?? ?private static Cookie aopcookie;//采集點定義
?? ?private static Cookie urlcookie;//來源頁面
?? ?private static Cookie lb1; //第三方預留參數。
?? ?private static Cookie lb2; //第三方預留參數。
?? ?private static Cookie lb3; //第三方預留參數。
?? ?private static Cookie lb4; //第三方預留參數。
?? ?private static Cookie lb5; //第三方預留參數。
?? ?
?? ?private static String lb1Str = null;
?? ?private static String lb2Str = null;
?? ?private static String lb3Str = null;
?? ?private static String lb4Str = null;
?? ?private static String lb5Str = null;
?? ?private static String[] aops = {"0"};
?? ?private static String backUrl=null;
?? ?private static String tid="";
?? ?
?? ?private static String unionCode = null; //簡單去重處理KEY
?? ?
?? ?/**
?? ? * 初始化
?? ? */
?? ?public static void init()
?? ?{
?? ??? ?fromcookie = Request.current().cookies.get(Constants.ADUNION_CPACPS_FROM);
?? ??? ?tidcookie = Request.current().cookies.get(Constants.ADUNION_CPACPS_TID);
?? ??? ?aopcookie = Request.current().cookies.get(Constants.ADUNION_AOP);
?? ??? ?urlcookie = Request.current().cookies.get(Constants.COOKIE_KEY_BACKURL+"in");
?? ??? ?lb1 = Request.current().cookies.get(Constants.ADUNION_AOP+"lb1");
?? ??? ?lb2 = Request.current().cookies.get(Constants.ADUNION_AOP+"lb2");
?? ??? ?lb3 = Request.current().cookies.get(Constants.ADUNION_AOP+"lb3");
?? ??? ?lb4 = Request.current().cookies.get(Constants.ADUNION_AOP+"lb4");
?? ??? ?lb5 = Request.current().cookies.get(Constants.ADUNION_AOP+"lb5");
?? ??? ?
?? ??? ?lb1Str = lb1!=null?lb1.value:null;
?? ??? ?lb2Str = lb2!=null?lb2.value:null;
?? ??? ?lb3Str = lb3!=null?lb3.value:null;
?? ??? ?lb4Str = lb4!=null?lb4.value:null;
?? ??? ?lb5Str = lb5!=null?lb5.value:null;
?? ??? ?if(aopcookie!=null)
?? ??? ?{
?? ??? ??? ?String aopStr = aopcookie.value;
?? ??? ??? ?if(aopStr!=null&&aopStr.length()>5)
?? ??? ??? ?{
?? ??? ??? ??? ?aops = aopStr.split("_");
?? ??? ??? ?}
?? ??? ?}
?? ??? ?
?? ??? ?if(urlcookie!=null){
?? ??? ??? ?String siteurl = urlcookie.value;
?? ??? ??? ?if(siteurl!=null)
?? ??? ??? ??? ?backUrl = siteurl.replace("[", "").replace("]", "");
?? ??? ?}
?? ??? ?
?? ??? ?if(tidcookie!=null){
?? ??? ??? ?tid = tidcookie.value;
?? ??? ??? ?if(tid!=null)
?? ??? ??? ??? ?tid = tid.replace("[", "").replace("]", "");
?? ??? ?}?? ?
?? ?}
???
注冊方法采集點,注冊完成后調用下面方法采集數據。
/**
?? ? * 廣告聯盟來的注冊? 采集點劉名雄
?? ? * 1_0_0_0_0 第一位為1
?? ? * @param user
?? ? */
public static void adUnionReg(User user)
?? ?{
?? ??? ?try{
?? ??? ??? ?init();
?? ??? ??? ?if(fromcookie!=null&&aops!=null&&aops.length>0&&aops[0].equals("1")) //開啟則采集
?? ??? ??? ?{
?? ??? ??? ??? ?String from = fromcookie.value;
?? ??? ??? ??? ?user.user_from = from;
?? ??? ??? ??? ?
?? ??? ??? ?
?? ??? ??? ??? ?t_adunion_result adunion = new t_adunion_result();
?? ??? ??? ??? ?adunion.cpa_param = tid;
?? ??? ??? ??? ?
?? ??? ??? ??? ?if(from!=null&&from.equalsIgnoreCase("yrt")) //需要回調通知注冊狀態
?? ??? ??? ??? ?{
?? ??? ??? ??? ??? ?String userid = Encrypt.encrypt3DES(user.id+"",Constants.HDCPACPSKEY);
?? ??? ??? ??? ??? ?String sign = Encrypt.MD5(user.cpa_param+userid+Constants.CPACPSKEY);
?? ??? ??? ??? ??? ?String cpsUrl = Constants.CPACPSAPIURL+"?tid="+user.cpa_param+"&uid="+userid+"&sign="+sign;
?? ??? ??? ??? ??? ?String cpsRet = WS.url(cpsUrl).get().getString();
?? ??? ??? ??? ??? ?adunion.cpa_result = cpsRet;
?? ??? ??? ??? ?}
?? ??? ??? ??? ?adunion.userid = user.id;
?? ??? ??? ??? ?adunion.user_from = from;
?? ??? ??? ??? ?adunion.cpa_param = user.cpa_param;
?? ??? ??? ??? ?adunion.addtime = new Date();
?? ??? ??? ??? ?adunion.aop = Arrays.toString(aops);
?? ??? ??? ??? ?if(backUrl==null){
?? ??? ??? ??? ??? ?backUrl = Request.current().headers.get("referer")+"";
?? ??? ??? ??? ??? ?backUrl = backUrl.replace("[", "").replace("]", "");
?? ??? ??? ??? ?}
?? ??? ??? ??? ?adunion.siteurl = backUrl;
?? ??? ??? ??? ?String ip = DataUtil.getIp();
?? ??? ??? ??? ?adunion.ip = ip;
?? ??? ??? ??? ?
?? ??? ??? ??? ?adunion.lb1 = lb1Str;
?? ??? ??? ??? ?adunion.lb2 = lb2Str;
?? ??? ??? ??? ?adunion.lb3 = lb3Str;
?? ??? ??? ??? ?adunion.lb4 = lb4Str;
?? ??? ??? ??? ?adunion.lb5 = lb5Str;
?? ??? ??? ??? ?
?? ??? ??? ??? ?adunion.save(); //記錄回調
?? ??? ??? ??? ?backUrl = null;
?? ??? ??? ?}
?? ??? ?}catch(Exception ex)
?? ??? ?{
?? ??? ??? ?ex.printStackTrace();
?? ??? ?}
?? ?}
/**
?? ? * 用戶提現點采集
?? ? * 0_0_0_0_1_1 第六位為1
?? ? * @param userid
?? ? * @param orderId
?? ? */
?? ?public static void adUnionLogin(long userid)
?? ?{
?? ??? ?try{
?? ??? ??? ?init();
?? ??? ??? ?if(fromcookie!=null&&aops!=null&&aops.length>5&&aops[5].equals("1"))
?? ??? ??? ?{
?? ??? ??? ??? ?t_adunion_result adunion = new t_adunion_result();
?? ??? ??? ??? ?
?? ??? ??? ??? ?String from = fromcookie.value;
?? ??? ??? ??? ?adunion.user_from = from;
?? ??? ??? ??? ?adunion.cpa_param = tid;
?? ??? ??? ?
?? ??? ??? ??? ?
?? ??? ??? ??? ?adunion.userid = userid;
?? ??? ??? ??? ?adunion.addtime = new Date();
?? ??? ??? ??? ?adunion.aop = Arrays.toString(aops);
?? ??? ??? ??? ?if(backUrl==null){
?? ??? ??? ??? ??? ?backUrl = Request.current().headers.get("referer")+"";
?? ??? ??? ??? ??? ?backUrl = backUrl.replace("[", "").replace("]", "");
?? ??? ??? ??? ?}
?? ??? ??? ??? ?adunion.siteurl = backUrl;
?? ??? ??? ??? ?String ip = DataUtil.getIp();
?? ??? ??? ??? ?adunion.ip = ip;
?? ??? ??? ??? ?
?? ??? ??? ??? ?adunion.lb1 = lb1Str;
?? ??? ??? ??? ?adunion.lb2 = lb2Str;
?? ??? ??? ??? ?adunion.lb3 = lb3Str;
?? ??? ??? ??? ?adunion.lb4 = lb4Str;
?? ??? ??? ??? ?adunion.lb5 = lb5Str;
?? ??? ??? ??? ?
?? ??? ??? ??? ?adunion.save();
?? ??? ??? ??? ?backUrl = null;
?? ??? ??? ?}
?? ??? ?}catch(Exception ex)
?? ??? ?{
?? ??? ??? ?ex.printStackTrace();
?? ??? ?}
?? ?}
總結
以上是生活随笔為你收集整理的自定义广告联盟接入解决方案,适用所有广告商接入。的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: CentOS防火墙配置(资源)
- 下一篇: LeetCode 热题100-76-比特