バナー広告
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
}
}
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形式で返されるため、Webプロジェクトで直接レンダリングできます。他のプラットフォームではWebViewを使用してレンダリングできます。
リクエストパラメータ
ヘッダー
App Key(adrop_service.jsonで確認)
クエリパラメータ
広告ユニットID
ユーザー固有識別子。広告配信頻度制御とターゲティングに使用されます。
プラットフォーム。
android、ios、webのいずれかロケール。例:
ja_JP、en_USテーマモード。
lightまたはdarkコンテキストターゲティングID(ターゲティング広告リクエスト時必須)
広告識別子(デバイスプレビュー時必須)
レスポンス
レスポンスコード。
0は成功を意味します。レスポンスメッセージ
{
"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
}
}
レンダリング
Webでのレンダリング
<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