curl \
-H "Authorization: Bearer API_KEY" \
-X GET "https://api.ayrshare.com/api/ads/facebook/cities?search=Manhattan"
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/facebook/cities?search=Manhattan", {
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/facebook/cities?search=Manhattan', headers=headers)
print(r.json())
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ayrshare.com/api/ads/facebook/cities?search=Manhattan",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer API_KEY"
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer API_KEY");
var response = await client.GetAsync("https://api.ayrshare.com/api/ads/facebook/cities?search=Manhattan");
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main() {
client := &http.Client{}
req, _ := http.NewRequest("GET", "https://api.ayrshare.com/api/ads/facebook/cities?search=Manhattan", nil)
req.Header.Add("Authorization", "Bearer API_KEY")
resp, _ := client.Do(req)
body, _ := ioutil.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 GetAdCities {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.ayrshare.com/api/ads/facebook/cities?search=Manhattan"))
.header("Authorization", "Bearer API_KEY")
.GET()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
require 'net/http'
require 'json'
uri = URI('https://api.ayrshare.com/api/ads/facebook/cities?search=Manhattan')
req = Net::HTTP::Get.new(uri)
req['Authorization'] = 'Bearer API_KEY'
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http|
http.request(req)
}
puts res.body
{
"status": "success",
"cities": [
{
"key": "2447439",
"name": "Manhattan",
"type": "city",
"countryCode": "US",
"countryName": "United States",
"region": "Kansas",
"regionId": 3859,
"supportsRegion": true,
"supportsCity": true
},
{
"key": "2703980",
"name": "Manhattan",
"type": "subcity",
"countryCode": "US",
"countryName": "United States",
"region": "New York",
"regionId": 3875,
"supportsRegion": true,
"supportsCity": true,
"geoHierarchyLevel": "SUBCITY",
"geoHierarchyName": "BOROUGH"
}
],
"count": 2
}
{
"action": "ads",
"status": "error",
"code": 414,
"message": "Error getting ad location metadata. Please try again."
}
Facebook Ads
Міста
Отримання міст для Facebook Ads за назвою
GET
/
ads
/
facebook
/
cities
curl \
-H "Authorization: Bearer API_KEY" \
-X GET "https://api.ayrshare.com/api/ads/facebook/cities?search=Manhattan"
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/facebook/cities?search=Manhattan", {
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/facebook/cities?search=Manhattan', headers=headers)
print(r.json())
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ayrshare.com/api/ads/facebook/cities?search=Manhattan",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer API_KEY"
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer API_KEY");
var response = await client.GetAsync("https://api.ayrshare.com/api/ads/facebook/cities?search=Manhattan");
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main() {
client := &http.Client{}
req, _ := http.NewRequest("GET", "https://api.ayrshare.com/api/ads/facebook/cities?search=Manhattan", nil)
req.Header.Add("Authorization", "Bearer API_KEY")
resp, _ := client.Do(req)
body, _ := ioutil.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 GetAdCities {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.ayrshare.com/api/ads/facebook/cities?search=Manhattan"))
.header("Authorization", "Bearer API_KEY")
.GET()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
require 'net/http'
require 'json'
uri = URI('https://api.ayrshare.com/api/ads/facebook/cities?search=Manhattan')
req = Net::HTTP::Get.new(uri)
req['Authorization'] = 'Bearer API_KEY'
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http|
http.request(req)
}
puts res.body
{
"status": "success",
"cities": [
{
"key": "2447439",
"name": "Manhattan",
"type": "city",
"countryCode": "US",
"countryName": "United States",
"region": "Kansas",
"regionId": 3859,
"supportsRegion": true,
"supportsCity": true
},
{
"key": "2703980",
"name": "Manhattan",
"type": "subcity",
"countryCode": "US",
"countryName": "United States",
"region": "New York",
"regionId": 3875,
"supportsRegion": true,
"supportsCity": true,
"geoHierarchyLevel": "SUBCITY",
"geoHierarchyName": "BOROUGH"
}
],
"count": 2
}
{
"action": "ads",
"status": "error",
"code": 414,
"message": "Error getting ad location metadata. Please try again."
}
Пошук міст для використання під час націлювання при просуванні реклами.
- Міста використовують ідентифікатор Facebook
keyта підтримують націлювання за радіусом. - Кожен результат міста містить його батьківський регіон як
region(назва регіону) таregionId(числовий ідентифікатор регіону), тож ви можете націлюватися на регіон міста, коли він доступний. - Якщо повернене місто має
supportsRegionзі значеннямtrue, регіон цього міста доступний для націлювання. ЯкщоsupportsCityдорівнюєtrue, це місто доступне для націлювання. - Деякі локації можуть повертатися як
subcityз додатковими полями ієрархії.
Параметри заголовка
Параметри запиту
Пошуковий рядок для фільтрації міст. Вкажіть часткову або повну назву міста.
Максимальна кількість міст, які потрібно повернути.
curl \
-H "Authorization: Bearer API_KEY" \
-X GET "https://api.ayrshare.com/api/ads/facebook/cities?search=Manhattan"
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/facebook/cities?search=Manhattan", {
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/facebook/cities?search=Manhattan', headers=headers)
print(r.json())
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ayrshare.com/api/ads/facebook/cities?search=Manhattan",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer API_KEY"
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer API_KEY");
var response = await client.GetAsync("https://api.ayrshare.com/api/ads/facebook/cities?search=Manhattan");
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main() {
client := &http.Client{}
req, _ := http.NewRequest("GET", "https://api.ayrshare.com/api/ads/facebook/cities?search=Manhattan", nil)
req.Header.Add("Authorization", "Bearer API_KEY")
resp, _ := client.Do(req)
body, _ := ioutil.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 GetAdCities {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.ayrshare.com/api/ads/facebook/cities?search=Manhattan"))
.header("Authorization", "Bearer API_KEY")
.GET()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
require 'net/http'
require 'json'
uri = URI('https://api.ayrshare.com/api/ads/facebook/cities?search=Manhattan')
req = Net::HTTP::Get.new(uri)
req['Authorization'] = 'Bearer API_KEY'
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http|
http.request(req)
}
puts res.body
{
"status": "success",
"cities": [
{
"key": "2447439",
"name": "Manhattan",
"type": "city",
"countryCode": "US",
"countryName": "United States",
"region": "Kansas",
"regionId": 3859,
"supportsRegion": true,
"supportsCity": true
},
{
"key": "2703980",
"name": "Manhattan",
"type": "subcity",
"countryCode": "US",
"countryName": "United States",
"region": "New York",
"regionId": 3875,
"supportsRegion": true,
"supportsCity": true,
"geoHierarchyLevel": "SUBCITY",
"geoHierarchyName": "BOROUGH"
}
],
"count": 2
}
{
"action": "ads",
"status": "error",
"code": 414,
"message": "Error getting ad location metadata. Please try again."
}
⌘I
