-
Notifications
You must be signed in to change notification settings - Fork 0
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
18 changed files
with
280 additions
and
44 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package advertiser | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/bububa/spotlight-mapi/core" | ||
"github.com/bububa/spotlight-mapi/model" | ||
"github.com/bububa/spotlight-mapi/model/oauth" | ||
) | ||
|
||
// AccessToken 获取accessToken | ||
func AccessToken(ctx context.Context, clt *core.SDKClient, advertiserID uint64) (*oauth.AccessToken, error) { | ||
req := model.CommonRequest{ | ||
AdvertiserID: advertiserID, | ||
Method: "oauth.getAccessToken", | ||
} | ||
var ret oauth.AccessTokenResponse | ||
if err := clt.Post(ctx, "/common", req, &ret, ""); err != nil { | ||
return nil, err | ||
} | ||
return ret.Data, 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package conversion | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/bububa/spotlight-mapi/core" | ||
"github.com/bububa/spotlight-mapi/model/conversion" | ||
) | ||
|
||
// App APP口令码数据回传 | ||
func App(ctx context.Context, clt *core.SDKClient, req *conversion.AppRequest) error { | ||
return clt.Post(ctx, "/app", 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package conversion | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/bububa/spotlight-mapi/core" | ||
"github.com/bububa/spotlight-mapi/model/conversion" | ||
) | ||
|
||
// AuroraLeads 线索转化数据回传 | ||
func AuroraLeads(ctx context.Context, clt *core.SDKClient, req *conversion.AuroraLeadsRequest) error { | ||
return clt.Post(ctx, "/common", 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,13 @@ | ||
package conversion | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/bububa/spotlight-mapi/core" | ||
"github.com/bububa/spotlight-mapi/model/conversion" | ||
) | ||
|
||
// HawkingLeads 聚光落地页线索数据回传 | ||
func HawkingLeads(ctx context.Context, clt *core.SDKClient, req *conversion.HawkingLeadsRequest) error { | ||
return clt.PostHawkingLeads(ctx, 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
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,10 +1,10 @@ | ||
package core | ||
|
||
const ( | ||
// BASE_URL 默认APIgateway | ||
// BASE_URL 默认API gateway | ||
BASE_URL = "https://adapi.xiaohongshu.com/api/open" | ||
// CONVERSION_URL 转化回传API gateway | ||
CONVERSION_URL = "https://adapi.xiaohongshu.com/api/open/conversion" | ||
// HAWKLING_LEADS_URL 聚光落地页线索数据回传API gateway | ||
HAWKLING_LEADS_URL = "http://www.xiaohongshu.com/api/hawking/leads/return" | ||
// OAUTH_URL oauth授权 gateway | ||
OAUTH_URL = "https://ad.xiaohongshu.com/aurora/openApiAuth" | ||
) |
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
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,50 @@ | ||
package conversion | ||
|
||
import ( | ||
"strconv" | ||
"time" | ||
|
||
"github.com/bububa/spotlight-mapi/enum" | ||
"github.com/bububa/spotlight-mapi/model" | ||
"github.com/bububa/spotlight-mapi/util" | ||
) | ||
|
||
// AppRequest APP口令码数据回传 API Request | ||
type AppRequest struct { | ||
// AdvertiserID 广告主id | ||
AdvertiserID model.JSONUint64 `json:"advertiser_id,omitempty"` | ||
// Version 接口版本, 固定为"1.0" | ||
Version string `json:"version,omitempty"` | ||
// Timestamp 当前时间戳, 时间戳格式,毫秒 | ||
Timestamp int64 `json:"timestamp,omitempty"` | ||
// OaidMd5 安卓广告标识符, 高版本,32位大写md5加密 | ||
OaidMd5 string `json:"oaid_md5,omitempty"` | ||
// CaidMd5 苹果广告标识符(20230330版), 高版本,32位大写md5加密 | ||
CaidMd5 string `json:"caid_md5,omitempty"` | ||
// TokenCode 口令码 | ||
TokenCode string `json:"token_code,omitempty"` | ||
// EventType 转化事件类型id | ||
EventType enum.EventType `json:"event_type,omitempty"` | ||
// ConvTime 转化事件发生时间 | ||
ConvTime int64 `json:"conv_time,omitempty"` | ||
// ReportSource 数据来源 | ||
ReportSource string `json:"report_source,omitempty"` | ||
// ForTest 是否是联调环境 | ||
ForTest bool `json:"for_test,omitempty"` | ||
// AccessToken access_token | ||
AccessToken string `json:"access_token,omitempty"` | ||
// Sign 签名 | ||
Sign string `json:"sign,omitempty"` | ||
} | ||
|
||
// Encode implement PostRequest interface | ||
func (r AppRequest) Encode() []byte { | ||
r.Timestamp = time.Now().UnixMilli() | ||
r.Sign = r.sign() | ||
return util.JSONMarshal(r) | ||
} | ||
|
||
func (r AppRequest) sign() string { | ||
raw := util.StringsJoin("advertiser_id", r.AdvertiserID.String(), "×tamp", strconv.FormatInt(r.Timestamp, 10), "&version", r.Version) | ||
return util.Md5String(raw) | ||
} |
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,48 @@ | ||
package conversion | ||
|
||
import ( | ||
"strconv" | ||
"time" | ||
|
||
"github.com/bububa/spotlight-mapi/enum" | ||
"github.com/bububa/spotlight-mapi/model" | ||
"github.com/bububa/spotlight-mapi/util" | ||
) | ||
|
||
// AuroraLeadsRequest 回传数据接口 API Request | ||
type AuroraLeadsRequest struct { | ||
// AdvertiserID 广告主id | ||
AdvertiserID model.JSONUint64 `json:"advertiser_id,omitempty"` | ||
// Version 接口版本, 固定为"1.0" | ||
Version string `json:"version,omitempty"` | ||
// Timestamp 当前时间戳, 时间戳格式,毫秒 | ||
Timestamp int64 `json:"timestamp,omitempty"` | ||
// Method 转发方法, 固定为"aurora.leads" | ||
Method string ` json:"method,omitempty"` | ||
// Token access_token | ||
Token string `json:"token,omitempty"` | ||
// EventType 转化事件类型 id | ||
EventType enum.EventType `json:"event_type,omitempty"` | ||
// ConvTime 转化发生时间, 时间戳格式,毫秒 | ||
ConvTime int64 `json:"conv_time,omitempty"` | ||
// ClickID 事件对应的click_id,同页面跳转click_id | ||
ClickID string `json:"click_id,omitempty"` | ||
// AccessToken access_token | ||
AccessToken string `json:"access_token,omitempty"` | ||
// Sign 签名 | ||
Sign string `json:"sign,omitempty"` | ||
} | ||
|
||
// Encode implement PostRequest | ||
func (r AuroraLeadsRequest) Encode() []byte { | ||
r.Version = "1.0" | ||
r.Method = "aurora.leads" | ||
r.Timestamp = time.Now().UnixMilli() | ||
r.Sign = r.sign() | ||
return util.JSONMarshal(r) | ||
} | ||
|
||
func (r AuroraLeadsRequest) sign() string { | ||
raw := util.StringsJoin("advertiser_id", r.AdvertiserID.String(), "&method", r.Method, "×tamp", strconv.FormatInt(r.Timestamp, 10), "&version", r.Version) | ||
return util.Md5String(raw) | ||
} |
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,20 @@ | ||
package conversion | ||
|
||
import "github.com/bububa/spotlight-mapi/util" | ||
|
||
// HawkingLeadsRequest 聚光落地页线索数据回传 API Request | ||
type HawkingLeadsRequest struct { | ||
// CampaignID 计划ID | ||
CampaignID uint64 `json:"campaignId,omitempty"` | ||
// UnitID 单元ID | ||
UnitID uint64 `json:"unitId,omitempty"` | ||
// CreativityID 创意ID | ||
CreativityID uint64 `json:"creativityId,omitempty"` | ||
// LeadsID | ||
LeadsID string `json:"leadsId,omitempty"` | ||
} | ||
|
||
// Encode implement PostRequest interface | ||
func (r HawkingLeadsRequest) Encode() []byte { | ||
return util.JSONMarshal(r) | ||
} |
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
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,9 @@ | ||
package oauth | ||
|
||
// Advertiser 广告主 | ||
type Advertiser struct { | ||
// ID 广告主ID | ||
ID uint64 `json:"advertiser_id,omitempty"` | ||
// Name 广告主名称 | ||
Name string `json:"advertiser_name,omitempty"` | ||
} |
Oops, something went wrong.