自定义广告联盟接入解决方案,适用所有广告商接入。
一、著陸頁(yè)說(shuō)明: 著陸頁(yè)及參數(shù)形式:http://www.xxx.cn/著陸頁(yè)?from=yrt&aop=1_1_0_1_1_1&tid=d000a26123454442dc4f3646922028e&lb1=1&lb2=2&lb3=3&lb4=4&lb5=5?? 。 任何一個(gè)頁(yè)面都可以當(dāng)作著陸頁(yè),
如:首頁(yè)著陸地址為:(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); 某專題頁(yè)著陸地址為:(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)。
二、入?yún)⒄f(shuō)明: ? ?? ? ??入?yún)⒉捎米帜浮?shù)字、下劃線表示。不建議采用中文漢字。
? ? 1、from: 來(lái)源;能唯一區(qū)別某網(wǎng)站的字符串,用字母和數(shù)字表示,不能為空。 如:baidu、163、yrt等等 ? ? 2、aop:數(shù)據(jù)采集點(diǎn)定義;目前定義了六個(gè)采集點(diǎn)(如需要還可添加)。格式1_1_0_1_1_1,分別表示注冊(cè)_綁卡_充值_交易_提現(xiàn)_登錄;每個(gè)對(duì)應(yīng)位上的值若為1表示開(kāi)啟采集,為0表示關(guān)閉采集。如:某廣告商進(jìn)來(lái)的用戶按注冊(cè)用戶及生產(chǎn)投資分成則該參數(shù)為:1_0_0_1_0_1。登錄位建議開(kāi)啟 3、tid:第三方回調(diào)參數(shù);若第三方需要回調(diào)作關(guān)聯(lián)則可傳此參數(shù)。一般在CPS上用到,如:武漢易瑞特的廣告平臺(tái)就需要用。 ? ? 4、lb1:終端類型;如:PC,WAP,APP等 ? ? 5、lb2:頻道或者專題類型;用以區(qū)別是同一網(wǎng)站的哪個(gè)地方來(lái)的。 ? ? 6、lb3:關(guān)鍵字識(shí)別代碼;如:1001對(duì)應(yīng)著百度搜索關(guān)鍵字“P2P”,1002對(duì)應(yīng)360搜索關(guān)鍵字“互聯(lián)網(wǎng)金融”,1003對(duì)應(yīng)百度搜索關(guān)鍵字:“互聯(lián)網(wǎng)金融”等。 ? ? 7、lb4:預(yù)留加密串;針對(duì)特殊情況需要檢驗(yàn)來(lái)源時(shí)和第三方約定。 ? ? 8、lb5:預(yù)留參數(shù);該參數(shù)用于以后擴(kuò)展。
在基類中獲取入?yún)⒉⒋鍯OOKIE
@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層中獲取參數(shù)并處理。
private static Cookie fromcookie; //來(lái)源
?? ?private static Cookie tidcookie;//第三方來(lái)參
?? ?private static Cookie aopcookie;//采集點(diǎn)定義
?? ?private static Cookie urlcookie;//來(lái)源頁(yè)面
?? ?private static Cookie lb1; //第三方預(yù)留參數(shù)。
?? ?private static Cookie lb2; //第三方預(yù)留參數(shù)。
?? ?private static Cookie lb3; //第三方預(yù)留參數(shù)。
?? ?private static Cookie lb4; //第三方預(yù)留參數(shù)。
?? ?private static Cookie lb5; //第三方預(yù)留參數(shù)。
?? ?
?? ?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; //簡(jiǎn)單去重處理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("]", "");
?? ??? ?}?? ?
?? ?}
???
注冊(cè)方法采集點(diǎn),注冊(cè)完成后調(diào)用下面方法采集數(shù)據(jù)。
/**
?? ? * 廣告聯(lián)盟來(lái)的注冊(cè)? 采集點(diǎn)劉名雄
?? ? * 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")) //開(kāi)啟則采集
?? ??? ??? ?{
?? ??? ??? ??? ?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")) //需要回調(diào)通知注冊(cè)狀態(tài)
?? ??? ??? ??? ?{
?? ??? ??? ??? ??? ?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(); //記錄回調(diào)
?? ??? ??? ??? ?backUrl = null;
?? ??? ??? ?}
?? ??? ?}catch(Exception ex)
?? ??? ?{
?? ??? ??? ?ex.printStackTrace();
?? ??? ?}
?? ?}
/**
?? ? * 用戶提現(xiàn)點(diǎn)采集
?? ? * 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();
?? ??? ?}
?? ?}
總結(jié)
以上是生活随笔為你收集整理的自定义广告联盟接入解决方案,适用所有广告商接入。的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: CentOS防火墙配置(资源)
- 下一篇: LeetCode 热题100-76-比特