curl \
-H "Authorization: Bearer API_KEY" \
-X GET "https://api.ayrshare.com/api/ads/google/campaigns/21534567890"
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/google/campaigns/21534567890", {
method: "GET",
headers: {
"Authorization": `Bearer ${API_KEY}`
}
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
headers = {
"Authorization": "Bearer API_KEY",
}
r = requests.get("https://api.ayrshare.com/api/ads/google/campaigns/21534567890", headers=headers)
print(r.json())
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ayrshare.com/api/ads/google/campaigns/21534567890",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer API_KEY"
]
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error: " . $err;
} else {
echo $response;
}
?>
using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer API_KEY");
var response = await client.GetAsync("https://api.ayrshare.com/api/ads/google/campaigns/21534567890");
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
}
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
req, _ := http.NewRequest("GET", "https://api.ayrshare.com/api/ads/google/campaigns/21534567890", nil)
req.Header.Add("Authorization", "Bearer API_KEY")
resp, err := http.DefaultClient.Do(req)
if err != nil {
fmt.Println("Error:", err)
return
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class GetCampaign {
public static void main(String[] args) throws Exception {
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.ayrshare.com/api/ads/google/campaigns/21534567890"))
.header("Authorization", "Bearer API_KEY")
.GET()
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
require 'net/http'
require 'uri'
uri = URI.parse('https://api.ayrshare.com/api/ads/google/campaigns/21534567890')
request = Net::HTTP::Get.new(uri)
request['Authorization'] = 'Bearer API_KEY'
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
puts response.body
{
"status": "success",
"platform": "google",
"campaignId": "21534567890",
"name": "Fall sale",
"campaignStatus": "active",
"platformStatus": "ENABLED",
"budget": { "amount": 25, "currency": "USD", "type": "daily" },
"ads": [
{
"adId": "71234567890",
"approvalStatus": "APPROVED_LIMITED",
"reviewStatus": "REVIEWED",
"policyTopics": [{ "topic": "ALCOHOL", "type": "LIMITED" }]
}
]
}
{
"status": "success",
"platform": "google",
"campaignId": "21534567891",
"name": "Fall sale PMax",
"campaignStatus": "paused",
"platformStatus": "PAUSED",
"budget": { "amount": 40, "currency": "USD", "type": "daily" },
"ads": [
{
"adId": "asset:6512345678~31234567890~HEADLINE",
"assetId": "31234567890",
"fieldType": "HEADLINE",
"primaryStatus": "ELIGIBLE",
"approvalStatus": "APPROVED",
"reviewStatus": "REVIEWED",
"policyTopics": []
}
]
}
{
"action": "ads",
"status": "error",
"code": 400,
"message": "Campaign not found or you are not authorized to access it."
}
Google Ads
Lấy Chiến dịch
Đọc trạng thái và ngân sách hằng ngày của một chiến dịch Google Ads, cùng kết quả xét duyệt của Google cho từng quảng cáo hoặc thành phần của chiến dịch.
GET
/
ads
/
google
/
campaigns
/
{id}
curl \
-H "Authorization: Bearer API_KEY" \
-X GET "https://api.ayrshare.com/api/ads/google/campaigns/21534567890"
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/google/campaigns/21534567890", {
method: "GET",
headers: {
"Authorization": `Bearer ${API_KEY}`
}
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
headers = {
"Authorization": "Bearer API_KEY",
}
r = requests.get("https://api.ayrshare.com/api/ads/google/campaigns/21534567890", headers=headers)
print(r.json())
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ayrshare.com/api/ads/google/campaigns/21534567890",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer API_KEY"
]
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error: " . $err;
} else {
echo $response;
}
?>
using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer API_KEY");
var response = await client.GetAsync("https://api.ayrshare.com/api/ads/google/campaigns/21534567890");
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
}
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
req, _ := http.NewRequest("GET", "https://api.ayrshare.com/api/ads/google/campaigns/21534567890", nil)
req.Header.Add("Authorization", "Bearer API_KEY")
resp, err := http.DefaultClient.Do(req)
if err != nil {
fmt.Println("Error:", err)
return
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class GetCampaign {
public static void main(String[] args) throws Exception {
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.ayrshare.com/api/ads/google/campaigns/21534567890"))
.header("Authorization", "Bearer API_KEY")
.GET()
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
require 'net/http'
require 'uri'
uri = URI.parse('https://api.ayrshare.com/api/ads/google/campaigns/21534567890')
request = Net::HTTP::Get.new(uri)
request['Authorization'] = 'Bearer API_KEY'
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
puts response.body
{
"status": "success",
"platform": "google",
"campaignId": "21534567890",
"name": "Fall sale",
"campaignStatus": "active",
"platformStatus": "ENABLED",
"budget": { "amount": 25, "currency": "USD", "type": "daily" },
"ads": [
{
"adId": "71234567890",
"approvalStatus": "APPROVED_LIMITED",
"reviewStatus": "REVIEWED",
"policyTopics": [{ "topic": "ALCOHOL", "type": "LIMITED" }]
}
]
}
{
"status": "success",
"platform": "google",
"campaignId": "21534567891",
"name": "Fall sale PMax",
"campaignStatus": "paused",
"platformStatus": "PAUSED",
"budget": { "amount": 40, "currency": "USD", "type": "daily" },
"ads": [
{
"adId": "asset:6512345678~31234567890~HEADLINE",
"assetId": "31234567890",
"fieldType": "HEADLINE",
"primaryStatus": "ELIGIBLE",
"approvalStatus": "APPROVED",
"reviewStatus": "REVIEWED",
"policyTopics": []
}
]
}
{
"action": "ads",
"status": "error",
"code": 400,
"message": "Campaign not found or you are not authorized to access it."
}
Lấy một chiến dịch Google Ads mà bạn đã tạo qua Ayrshare: tên, trạng thái, ngân sách hằng ngày và kết quả xét duyệt của Google cho từng quảng cáo của chiến dịch.
Quảng cáo không được phê duyệt sẽ không được phân phối. Hãy thay đổi quảng cáo trong Google Ads, hoặc tạo một chiến dịch mới với văn bản tuân thủ chính sách.
Tên doanh nghiệp, logo và logo ngang là các thành phần thương hiệu, được liên kết với chiến dịch thay vì nhóm thành phần. Chúng cũng có dòng ở đây, sau các dòng của nhóm thành phần, với khóa là ID chiến dịch:
Tham số Header
Tham số Path
string
bắt buộc
campaignId được trả về khi bạn tạo chiến dịch.Phản hồi
| Trường | Nội dung |
|---|---|
campaignId | Id của chiến dịch |
name | Tên chiến dịch |
campaignStatus | active hoặc paused |
platformStatus | Trạng thái riêng của Google: ENABLED, PAUSED, hoặc REMOVED đối với chiến dịch đã bị xóa trong Google Ads. Chiến dịch đã bị xóa giữ campaignStatus cuối cùng mà bạn đặt qua Ayrshare |
budget | Ngân sách hằng ngày: amount, currency (đơn vị tiền tệ của tài khoản quảng cáo) và type (daily) |
ads | Kết quả xét duyệt của Google cho từng quảng cáo (Search) hoặc thành phần (Performance Max). Xem Xét duyệt quảng cáo |
Xét duyệt quảng cáo
Google xét duyệt mọi quảng cáo mới theo các chính sách quảng cáo của mình, thường trong vòng một ngày làm việc. Mỗi dòng trongads chứa:
| Trường | Nội dung |
|---|---|
adId | Id của quảng cáo, như được trả về từ Create |
approvalStatus | Quyết định của Google: APPROVED, APPROVED_LIMITED (hiển thị có giới hạn, ví dụ không hiển thị ở một số quốc gia), AREA_OF_INTEREST_ONLY hoặc DISAPPROVED. Cho đến khi Google quyết định, trường này chứa một giá trị khác, chẳng hạn UNKNOWN hoặc UNSPECIFIED |
reviewStatus | Tình trạng của quá trình xét duyệt, ví dụ REVIEW_IN_PROGRESS hoặc REVIEWED |
policyTopics | Các chính sách dẫn đến giới hạn hoặc việc không phê duyệt: [{ "topic": "ALCOHOL", "type": "PROHIBITED" }] |
ads sẽ bị bỏ qua khi không thể đọc kết quả xét duyệt của Google vào thời điểm đó, hoặc khi việc đọc mất hơn vài giây; hãy đọc lại chiến dịch sau.
Mỗi đêm, Ayrshare cũng kiểm tra mọi kết quả xét duyệt và gửi một webhook ads với type: "reviewChanged" khi quyết định của Google thay đổi. Xem Ads Action.
Xét duyệt thành phần
Google xét duyệt riêng từng thành phần của chiến dịch Performance Max.ads chứa mỗi thành phần một dòng, với cùng các trường như xét duyệt quảng cáo, cộng thêm:
| Trường | Nội dung |
|---|---|
adId | Khóa của thành phần trong chiến dịch này: asset:<assetGroupId>~<assetId>~<fieldType>, hoặc asset:<campaignId>~<assetId>~<fieldType> với thành phần thương hiệu |
assetId | Id của thành phần trên Google |
fieldType | Nơi thành phần được sử dụng, ví dụ HEADLINE, MARKETING_IMAGE, SQUARE_MARKETING_IMAGE, BUSINESS_NAME hoặc LOGO |
primaryStatus | Thành phần có thể được phân phối hay không, ví dụ ELIGIBLE hoặc NOT_ELIGIBLE |
asset:<campaignId>~<assetId>~<fieldType>, trong đó fieldType là BUSINESS_NAME, LOGO hoặc LANDSCAPE_LOGO.
Lỗi
| Mã | Khi nào |
|---|---|
400 | Chiến dịch không thuộc về bạn, không tồn tại, hoặc không còn trong tài khoản Google Ads. Cũng xảy ra khi người dùng Google mà bạn liên kết không thể truy cập tài khoản quảng cáo, hoặc quyền truy cập Google Ads đã bị thu hồi. |
370 | Google không thể hoàn tất yêu cầu. Hãy thử lại. |
curl \
-H "Authorization: Bearer API_KEY" \
-X GET "https://api.ayrshare.com/api/ads/google/campaigns/21534567890"
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/google/campaigns/21534567890", {
method: "GET",
headers: {
"Authorization": `Bearer ${API_KEY}`
}
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
headers = {
"Authorization": "Bearer API_KEY",
}
r = requests.get("https://api.ayrshare.com/api/ads/google/campaigns/21534567890", headers=headers)
print(r.json())
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ayrshare.com/api/ads/google/campaigns/21534567890",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer API_KEY"
]
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error: " . $err;
} else {
echo $response;
}
?>
using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer API_KEY");
var response = await client.GetAsync("https://api.ayrshare.com/api/ads/google/campaigns/21534567890");
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
}
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
req, _ := http.NewRequest("GET", "https://api.ayrshare.com/api/ads/google/campaigns/21534567890", nil)
req.Header.Add("Authorization", "Bearer API_KEY")
resp, err := http.DefaultClient.Do(req)
if err != nil {
fmt.Println("Error:", err)
return
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class GetCampaign {
public static void main(String[] args) throws Exception {
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.ayrshare.com/api/ads/google/campaigns/21534567890"))
.header("Authorization", "Bearer API_KEY")
.GET()
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
require 'net/http'
require 'uri'
uri = URI.parse('https://api.ayrshare.com/api/ads/google/campaigns/21534567890')
request = Net::HTTP::Get.new(uri)
request['Authorization'] = 'Bearer API_KEY'
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
puts response.body
{
"status": "success",
"platform": "google",
"campaignId": "21534567890",
"name": "Fall sale",
"campaignStatus": "active",
"platformStatus": "ENABLED",
"budget": { "amount": 25, "currency": "USD", "type": "daily" },
"ads": [
{
"adId": "71234567890",
"approvalStatus": "APPROVED_LIMITED",
"reviewStatus": "REVIEWED",
"policyTopics": [{ "topic": "ALCOHOL", "type": "LIMITED" }]
}
]
}
{
"status": "success",
"platform": "google",
"campaignId": "21534567891",
"name": "Fall sale PMax",
"campaignStatus": "paused",
"platformStatus": "PAUSED",
"budget": { "amount": 40, "currency": "USD", "type": "daily" },
"ads": [
{
"adId": "asset:6512345678~31234567890~HEADLINE",
"assetId": "31234567890",
"fieldType": "HEADLINE",
"primaryStatus": "ELIGIBLE",
"approvalStatus": "APPROVED",
"reviewStatus": "REVIEWED",
"policyTopics": []
}
]
}
{
"action": "ads",
"status": "error",
"code": 400,
"message": "Campaign not found or you are not authorized to access it."
}