-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
481 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,11 @@ | ||
package ocpc | ||
|
||
import ( | ||
"encoding/json" | ||
"net/http" | ||
|
||
"github.com/bububa/baidu-marketing/model/ocpc" | ||
"github.com/bububa/baidu-marketing/core" | ||
"github.com/bububa/baidu-marketing/model" | ||
) | ||
|
||
// ActionCb APP转化数据收集 | ||
func ActionCb(req *ocpc.ActionCbRequest) error { | ||
httpReq, err := http.NewRequest("GET", req.Url(), nil) | ||
if err != nil { | ||
return err | ||
} | ||
httpReq.Header.Add("Content-Type", "application/json") | ||
httpResp, err := http.DefaultClient.Do(httpReq) | ||
if err != nil { | ||
return err | ||
} | ||
defer httpResp.Body.Close() | ||
var resp ocpc.ActionCbResponse | ||
err = json.NewDecoder(httpResp.Body).Decode(&resp) | ||
if err != nil { | ||
return err | ||
} | ||
if resp.IsError() { | ||
return resp | ||
} | ||
return nil | ||
func ActionCb(clt *core.SDKClient, req model.ActionCbRequest) error { | ||
return clt.ActionCb(req) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package ocpc | ||
|
||
import "github.com/bububa/baidu-marketing/util" | ||
|
||
var defaultFields = map[string]string{ | ||
"advertiser_id": "__USER_ID__", | ||
"cid": "__IDEA_ID__", | ||
"campaign_id": "__PLAN_ID__", | ||
"aid": "__UNIT_ID__", | ||
"word_id": "__WORD_ID__", | ||
"callback_url": "__CALLBACK_URL__", | ||
"ext_info": "__EXT_INFO__", | ||
"clickid": "__CLICK_ID__", | ||
"idfa": "__IDFA__", | ||
"imei": "__IMEI__", | ||
"android_id": "__ANDROIDID__", | ||
"oaid_md5": "__OAID_MD5__", | ||
"oaid": "__OAID__", | ||
"caid": "__CAID__", | ||
"ts": "__TS__", | ||
"os_type": "__OS_TYPE__", | ||
"bd_vid": "__BD_VID__", | ||
} | ||
|
||
func ClickMonitorUrl(baseUrl string, fields []string, version int) { | ||
values := util.GetUrlValues() | ||
defer util.PutUrlValues(values) | ||
for _, f := range fields { | ||
if version == 2 && f == "callback_ur" { | ||
continue | ||
} | ||
if v, ok := defaultFields[f]; ok { | ||
values.Set(f, v) | ||
} | ||
} | ||
if version == 2 { | ||
values.Set("callType", "v2") | ||
} else { | ||
values.Set("callType", "v1") | ||
} | ||
values.Set("sign", "__SIGN__") | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,13 @@ | ||
package ocpc | ||
|
||
import ( | ||
"bytes" | ||
"encoding/json" | ||
|
||
"github.com/bububa/baidu-marketing/core" | ||
"github.com/bububa/baidu-marketing/model" | ||
"github.com/bububa/baidu-marketing/model/ocpc" | ||
) | ||
|
||
// UploadConvertData 广告主回传转化数据接口 | ||
// 广告主通过调用该接口,将匹配到的转化数据发送给百度服务器。 | ||
func UploadConvertData(clt *core.SDKClient, req *ocpc.UploadConvertDataRequest) error { | ||
if req.Token == "" { | ||
req.Token = clt.OcpcToken() | ||
} | ||
buffer := &bytes.Buffer{} | ||
encoder := json.NewEncoder(buffer) | ||
encoder.SetEscapeHTML(false) | ||
err := encoder.Encode(req) | ||
if err != nil { | ||
return err | ||
} | ||
var resp ocpc.Response | ||
err = clt.Post(UPLOAD_CONVERT_DATA_URL, buffer.Bytes(), &resp) | ||
if err != nil { | ||
return err | ||
} | ||
if resp.IsError() { | ||
return resp | ||
} | ||
return nil | ||
func UploadConvertData(clt *core.SDKClient, req *ocpc.UploadConvertDataRequest) (*model.ResponseHeader, error) { | ||
return clt.Conversion(req, nil) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,13 @@ | ||
package ocpc | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/bububa/baidu-marketing/core" | ||
"github.com/bububa/baidu-marketing/model" | ||
"github.com/bububa/baidu-marketing/model/ocpc" | ||
) | ||
|
||
// UploadInvalidConvertData 广告主回传无效转化数据接口 | ||
// 广告主通过调用该接口,将认为是无效的转化数据发送给百度服务器。 | ||
func UploadInvalidConvertData(clt *core.SDKClient, req *ocpc.UploadInvalidConvertDataRequest) error { | ||
if req.Token == "" { | ||
req.Token = clt.Token() | ||
} | ||
reqBytes, err := json.Marshal(req) | ||
if err != nil { | ||
return err | ||
} | ||
var resp ocpc.Response | ||
err = clt.Post(UPLOAD_CONVERT_DATA_URL, reqBytes, &resp) | ||
if err != nil { | ||
return err | ||
} | ||
if resp.IsError() { | ||
return resp | ||
} | ||
return nil | ||
func UploadInvalidConvertData(clt *core.SDKClient, req *ocpc.UploadInvalidConvertDataRequest) (*model.ResponseHeader, error) { | ||
return clt.Conversion(req, nil) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package enum | ||
|
||
// Atype 表明用户的转化数据 | ||
type AType string | ||
|
||
const ( | ||
// AType_ACTIVATE 激活 | ||
AType_ACTIVATE AType = "activate" | ||
// ATYPE_REGISTER 注册 | ||
AType_REGISTER AType = "register" | ||
// ATYPE_ORDERS 付费(成单) | ||
AType_ORDERS AType = "orders" | ||
// ATYPE_RETAIN_1DAY 次日留存 | ||
AType_RETAIN_1DAY AType = "retain_1day" | ||
// AType_USER_DEFINED 客户自定义 | ||
AType_USER_DEFINED AType = "user_defined" | ||
// AType_ECBuy 商品下单成功 | ||
AType_ECBuy AType = "ec_buy" | ||
// AType_DEEP_PAGE_ACCESS 深度页面访问 | ||
AType_DEEP_PAGE_ACCESS AType = "deep_page_access" | ||
// ATYPE_CREDT_GRANTING 授信 | ||
AType_CREDT_GRANTING AType = "credit_granting" | ||
// AType_DEEPLINK 应用调起 | ||
AType_DEEPLINK AType = "deep_link" | ||
// AType_FEED_DEEPLINK 应用调起 | ||
AType_FEED_DEEPLINK AType = "feed_deeplink" | ||
// AType_PAY_TO_READ 付费阅读 | ||
AType_PAY_TO_READ AType = "pay_to_read" | ||
// AType_ENTER_BOOKSTORE_READ 进入书城阅读 | ||
AType_ENTER_BOOKSTORE_READ AType = "enter_bookstore_read" | ||
// AType_ADD_TO_DESKTOP 添加到桌面 | ||
AType_ADD_TO_DESKTOP AType = "add_to_desktop" | ||
// AType_LOGIN 登录 | ||
AType_LOGIN AType = "log_in" | ||
// AType_ORDER_SUBMIT_SUCCESS 订单提交成功 | ||
AType_ORDER_SUBMIT_SUCCESS AType = "order_submit_success" | ||
// AType_PAY_TO_WATCH 付费观剧 | ||
AType_PAY_TO_WATCH AType = "pay_to_watch" | ||
// AType_KEY_ACTION 关键行为 | ||
AType_KEY_ACTION AType = "key_action" | ||
// AType_DERIVED_EVENT 衍生事件 | ||
AType_DERIVED_EVENT AType = "derived_event" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package enum | ||
|
||
// ActType 请求类型 | ||
type ActType int | ||
|
||
const ( | ||
// ActType_CLICK 点击请求 | ||
ActType_CLICK ActType = 2 | ||
// ActType_IMPRESSION 曝光请求 | ||
ActType_IMPRESSION ActType = 3 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.