-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquick-start.sh
More file actions
77 lines (65 loc) · 2.11 KB
/
quick-start.sh
File metadata and controls
77 lines (65 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
#
# Trillboards Partner API - curl Quick Start
#
# This script demonstrates the 3-step integration:
# 1. Get VAST configuration (cache for 1 hour)
# 2. Fetch VAST from Google Ad Manager (Trillboards not in critical path)
# 3. Report impressions after ad completion
#
# Usage:
# export TRILLBOARDS_API_KEY=trb_partner_xxx
# ./quick-start.sh
#
set -e
API_BASE="${TRILLBOARDS_API_URL:-https://api.trillboards.com}"
API_KEY="${TRILLBOARDS_API_KEY}"
if [ -z "$API_KEY" ]; then
echo "Error: Set TRILLBOARDS_API_KEY environment variable"
exit 1
fi
echo "=========================================="
echo "Trillboards Partner API - Quick Start"
echo "=========================================="
echo ""
# Step 1: Get VAST configuration
echo "1. Fetching VAST configuration..."
echo ""
CONFIG=$(curl -s -H "Authorization: Bearer $API_KEY" \
"$API_BASE/v1/partner/vast/config")
echo "Response:"
echo "$CONFIG" | jq '.' 2>/dev/null || echo "$CONFIG"
echo ""
# Extract VAST tag URL (requires jq)
if command -v jq &> /dev/null; then
VAST_URL=$(echo "$CONFIG" | jq -r '.data.vast_tag_template // "N/A"')
echo "VAST Tag URL: $VAST_URL"
fi
echo ""
# Step 2: In production, your player fetches VAST directly from Google
echo "2. Your player fetches VAST directly from Google Ad Manager"
echo " (Google IMA SDK handles this - Trillboards not in critical path)"
echo ""
# Step 3: Report impression
echo "3. Reporting impression after ad completion..."
echo ""
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
RESULT=$(curl -s -X POST \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d "{
\"impressions\": [{
\"device_id\": \"demo-device-001\",
\"ad_id\": \"ima_demo_ad_123\",
\"event\": \"complete\",
\"timestamp\": \"$TIMESTAMP\",
\"duration_ms\": 15000
}]
}" \
"$API_BASE/v1/partner/tracking/batch")
echo "Response:"
echo "$RESULT" | jq '.' 2>/dev/null || echo "$RESULT"
echo ""
echo "=========================================="
echo "Integration complete!"
echo "=========================================="