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
Städte
Facebook-Werbestädte nach Namen abrufen
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."
}
Suchen Sie nach Städten, die beim Bewerben einer Anzeige für das Targeting verwendet werden sollen.
- Städte verwenden den
key-Bezeichner von Facebook und unterstützen Radius-Targeting. - Jedes Städteergebnis enthält seine übergeordnete Region als
region(den Regionsnamen) undregionId(die numerische Kennung der Region), sodass Sie die Region der Stadt gezielt ansteuern können, sofern verfügbar. - Wenn bei einer zurückgegebenen Stadt
supportsRegiongleichtrueist, ist die Region dieser Stadt für das Targeting verfügbar. WennsupportsCitygleichtrueist, ist diese Stadt für das Targeting verfügbar. - Einige Orte können als
subcitymit zusätzlichen Hierarchiefeldern zurückgegeben werden.
Header-Parameter
Query-Parameter
Die Suchzeichenfolge zum Filtern von Städten. Geben Sie einen teilweisen oder vollständigen Städtenamen an.
Maximale Anzahl der zurückzugebenden Städte.
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
