REST API
배너 광고
REST API를 사용하여 배너 광고를 요청하는 방법을 안내합니다.
GET
/
request
배너 광고
curl --request GET \
--url https://api-v2.adrop.io/request \
--header 'Authorization: <authorization>'import requests
url = "https://api-v2.adrop.io/request"
headers = {"Authorization": "<authorization>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: '<authorization>'}};
fetch('https://api-v2.adrop.io/request', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-v2.adrop.io/request",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api-v2.adrop.io/request"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api-v2.adrop.io/request")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-v2.adrop.io/request")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_body{
"code": 0,
"msg": "OK",
"result": {
"id": "ad_123456",
"format": "banner",
"type": "display",
"unit": "YOUR_UNIT_ID",
"w": 320,
"h": 100,
"ad": "<div>...</div>",
"target": "external",
"carouselActivated": false
}
}
배너 광고는 HTML 형식으로 반환되므로 웹 프로젝트에서 직접 렌더링할 수 있습니다. 다른 플랫폼에서는 WebView를 사용하여 렌더링할 수 있습니다.
요청 파라미터
헤더
쿼리 파라미터
문맥 타겟팅용 Context ID(선택). 콘솔의 문맥 타겟팅 옵션 조건에 입력한 값과 정확히 일치해야 합니다. 타겟팅 설정을 참고하세요.
응답
{
"code": 0,
"msg": "OK",
"result": {
"id": "ad_123456",
"format": "banner",
"type": "display",
"unit": "YOUR_UNIT_ID",
"w": 320,
"h": 100,
"ad": "<div>...</div>",
"target": "external",
"carouselActivated": false
}
}
렌더링
웹에서 렌더링
<div id="ad-container"></div>
<script>
fetch('https://api-v2.adrop.io/request?unit=YOUR_UNIT_ID&uid=USER_ID&pf=web', {
headers: { 'Authorization': 'YOUR_APP_KEY' }
})
.then(res => res.json())
.then(data => {
if (data.code === 0) {
document.getElementById('ad-container').innerHTML = data.result.ad;
}
});
</script>
캐러셀 배너
캐러셀 배너를 사용하는 경우 아래 스크립트를 추가해야 합니다:<script src="https://storage.adrop.io/js/adrop-carousel-1.0.1.min.js"></script>
관련 문서
네이티브 광고
커스텀 UI로 광고 구현
에러 코드
에러 처리 방법
이 페이지가 도움이 되었나요?
⌘I
배너 광고
curl --request GET \
--url https://api-v2.adrop.io/request \
--header 'Authorization: <authorization>'import requests
url = "https://api-v2.adrop.io/request"
headers = {"Authorization": "<authorization>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: '<authorization>'}};
fetch('https://api-v2.adrop.io/request', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-v2.adrop.io/request",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api-v2.adrop.io/request"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api-v2.adrop.io/request")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-v2.adrop.io/request")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_body{
"code": 0,
"msg": "OK",
"result": {
"id": "ad_123456",
"format": "banner",
"type": "display",
"unit": "YOUR_UNIT_ID",
"w": 320,
"h": 100,
"ad": "<div>...</div>",
"target": "external",
"carouselActivated": false
}
}