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
Villes
Obtenir les villes pour les annonces Facebook par nom
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."
}
Recherchez des villes à utiliser pour le ciblage lors de la sponsorisation d’une annonce.
- Les villes utilisent l’identifiant
keyde Facebook et prennent en charge le ciblage par rayon. - Chaque résultat de ville inclut sa région parente sous forme de
region(le nom de la région) etregionId(l’identifiant numérique de la région), afin que vous puissiez cibler la région de la ville lorsqu’elle est disponible. - Si une ville renvoyée a
supportsRegiontrue, la région pour cette ville est disponible pour le ciblage. SisupportsCityesttrue, cette ville est disponible pour le ciblage. - Certaines localisations peuvent être renvoyées comme
subcityavec des champs de hiérarchie supplémentaires.
Paramètres d’en-tête
Paramètres de requête
La chaîne de recherche pour filtrer les villes. Fournissez un nom de ville partiel ou complet.
Nombre maximum de villes à renvoyer.
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
