Dapatkan deskripsi yang dapat dibaca manusia untuk set spesifikasi penargetan. Untuk membaca deskripsi penargetan untuk ads
tertentu, setel HTTP GET
ke https://graph.facebook.com/{AD_ID}/targetingsentencelines
.
Untuk mendapatkan koneksi targetingsentencelines
bagi iklan yang sudah ada:
use FacebookAds\Object\Ad;
$ad = new Ad(<AD_ID>);
$targeting_description = $ad->getTargetingDescription();
// Output targeting description
foreach ($targeting_description->targetingsentencelines as $description) {
echo $description['content'].PHP_EOL;
foreach ($description['children'] as $child) {
echo "\t".$child.PHP_EOL;
}
}
from facebookads.adobjects.ad import Ad
ad = Ad(<AD_ID>)
targeting_description = ad.get_targeting_sentence_lines().get_one()
# Output the targeting description
for description in targeting_description['targetingsentencelines']:
print(description['content'])
for child in description['children']:
print("\t" + child)
curl -G \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.5/<AD_ID>/targetingsentencelines
Tanggapan:
{ "id": "<AD_ID>/targetingsentencelines", "targetingsentencelines": [ { "content": "Location - Living In:", "children": [ "Japan", "United States" ] }, { "content": "Age:", "children": [ "20 - 24" ] }, { "content": "Gender:", "children": [ "Male" ] }] }
Tanggapan berisi kolom berikut:
Nama | Deskripsi |
---|---|
jenis: string | ID |
jenis: array objek JSON | Deskripsi yang dapat dibaca manusia dari spesifikasi penargetan. Setiap objek berisi |
Anda juga bisa mendapatkan deskripsi penargetan untuk spesifikasi penargetan dengan HTTP GET
untuk akun iklan di https://graph.facebook.com/{AD_ACCOUNT_ID}/targetingsentencelines
.
Misalnya, untuk mendapatkan deskripsi penargetan bagi orang yang tinggal di AS atau Jepang, dan merupakan pria dengan usia antara 20-24:
use FacebookAds\Object\AdAccount;
use FacebookAds\Object\Fields\TargetingFields;
use FacebookAds\Object\Targeting;
$account = new AdAccount('act_<AD_ACCOUNT_ID>');
$targeting = new Targeting();
$targeting->setData(array(
TargetingFields::GEO_LOCATIONS => array(
'countries' => array('US', 'JP')
),
TargetingFields::GENDERS => array(1),
TargetingFields::AGE_MIN => 20,
TargetingFields::AGE_MAX => 24,
));
$params = array(
'targeting_spec' => $targeting->exportData(),
);
foreach ($account->getTargetingSentenceLines(array(), $params) as $description) {
echo $description->{'content'}.PHP_EOL;
foreach ($description->{'children'} as $child) {
echo " - ".$child.PHP_EOL;
}
}
from facebookads.adobjects.adaccount import AdAccount
from facebookads.adobjects.targeting import Targeting
account = AdAccount('act_<AD_ACCOUNT_ID>')
params = {
'targeting_spec': {
Targeting.Field.geo_locations: {
Targeting.Field.countries: ['US', 'JP'],
},
Targeting.Field.genders: [1],
Targeting.Field.age_min: 20,
Targeting.Field.age_max: 24,
},
}
targeting_description = account.get_targeting_sentence_lines(params=params) \
.get_one()
# Output the targeting description
for description in targeting_description['targetingsentencelines']:
print(description['content'])
for child in description['children']:
print("\t" + child)
curl -G \
--data-urlencode 'targeting_spec={
"age_max": 24,
"age_min": 20,
"genders": [1],
"geo_locations": {"countries":["US","JP"]}
}' \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.11/act_<AD_ACCOUNT_ID>/targetingsentencelines
Tanggapan:
{ "params": { "genders": [1], "age_min": 20, "age_max": 24, "geo_locations": { "countries": [ "US", "JP" ] } }, "targetingsentencelines": [{ "content": "Location - Living In:", "children": [ "Japan", "United States" ] }, { "content": "Age:", "children": [ "20 - 24" ] }, { "content": "Gender:", "children": [ "Male" ] }] }
Parameter tambahan meliputi:
Nama | Deskripsi |
---|---|
jenis: objek JSON | Wajib. Dapatkan deskripsi penargetan untuk spesifikasi penargetan ini. |
jenis: bool | Opsional. Apakah tanggapan meminta |
Tanggapan memiliki kolom berikut:
Nama | Deskripsi |
---|---|
jenis: array objek JSON | Deskripsi yang dapat dibaca manusia dari spesifikasi penargetan. Setiap objek memiliki |
jenis: objek JSON | Spesifikasi penargetan yang Anda masukkan. |