func (this *ReqRedisModule) fill_material(ad *context.AdInfo, material *jesgoo_protocol.Material) (err error) { if ad.Adid != int64(*material.Id) { err = errors.New("id is not equal") return } /* switch *material.Type { case jesgoo_protocol.Material_TEXT: if ad.AdType != context.TEXT { str := fmt.Sprintf("adid[%d] is not TEXT in bs", ad.Adid) err = errors.New(str) return } case jesgoo_protocol.Material_IMAGE: if ad.AdType != context.IMAGE { str := fmt.Sprintf("adid[%d] is not IMAGE in bs", ad.Adid) err = errors.New(str) return } case jesgoo_protocol.Material_ICON_TEXT: if ad.AdType != context.TEXT_ICON { str := fmt.Sprintf("adid[%d] is not ICON_TEXT in bs", ad.Adid) err = errors.New(str) return } default: str := fmt.Sprintf("adid[%d] is UNKNOWN is bs", ad.Adid) err = errors.New(str) return } */ if material.Title != nil { ad.Title = *material.Title } if material.Description != nil { ad.Description1 = *material.Description } if material.Image != nil { ad.ImageUrl = *material.Image.Url } if material.TargetUrl != nil { ad.ClickUrl = *material.TargetUrl } if material.App != nil { ad.Appname = *material.App.Name ad.Package = *material.App.PackageName ad.LogoUrl = *material.App.Logo.Url if material.App.PackageSize != nil { ad.PackageSize = (*material.App.PackageSize) >> 20 } } if material.LongDescription != nil { ad.Description2 = *material.LongDescription } ad.MaterialReady = true return }
func (this *ReqJesgooModule) parse_resp(ret_ads *[]context.AdInfo, bs_resp *ui2bs.BSResponse, adtype AdType) { if bs_resp.Ads == nil { return } var ad_num int ad_num = len(bs_resp.Ads) utils.DebugLog.Write("get jesgoo ad num [%d]", ad_num) for i := 0; i < ad_num; i++ { var tmpad context.AdInfo tmpad.MaterialReady = false this.convert_resp_ad(&tmpad, bs_resp.Ads[i], adtype) *ret_ads = append(*ret_ads, tmpad) } }
func (this *ReqQiushiModule) parse_resp(response *mobads_api.BidResponse, adtype AdType, inner_ads *[]context.AdInfo, bd_appsid string) (err error) { utils.DebugLog.Write("baidu_response [%s]", response.String()) if response.ErrorCode != nil { utils.WarningLog.Write("request qiushi fail . error_code is %u", *response.ErrorCode) errstr := fmt.Sprintf("request qiushi fail . errcode[%d]", *response.ErrorCode) err = errors.New(errstr) return } for i := 0; i < len(response.Ads); i++ { var inner_ad context.AdInfo inner_ad.MaterialReady = true err = this.convert_ad(&inner_ad, adtype, response.Ads[i], bd_appsid) if err != nil { continue } *inner_ads = append(*inner_ads, inner_ad) } return }