這似乎爲我的目的工作。
我從facebook-php-ads-sdk複製了一些代碼作爲解決方法。
$audience = new CustomAudience($audienceId);
$params = $this->formatParams($entriesArray, $inputType, [], false);
$audience->createUser([], $params, false);
/**
* Copied this from Facebook's https://github.com/facebook/facebook-php-ads-sdk/blob/d51193b19d730ae9274d45540986e1ac311b074d/src/FacebookAds/Object/CustomAudience.php#L363
* Take users and format them correctly for the request
*
* @param array $users
* @param string $type
* @param array $app_ids
* @param bool $is_hashed
* @return array
*/
protected function formatParams(array $users, $type, array $app_ids = array(), $is_hashed = false) {
if ($type == CustomAudienceTypes::EMAIL || $type == CustomAudienceTypes::PHONE) {
$normalizer = new EmailNormalizer();
$hash_normalizer = new HashNormalizer();
foreach ($users as &$user) {
if ($type == CustomAudienceTypes::EMAIL) {
$user = $normalizer->normalize(CustomAudienceTypes::EMAIL, $user);
}
if (!$is_hashed) {
$user = $hash_normalizer->normalize(
CustomAudienceTypes::EMAIL, $user);
}
}
}
$payload = array(
'schema' => $type,
'data' => $users,
);
if ($type === CustomAudienceTypes::ID) {
if (empty($app_ids)) {
throw new \InvalidArgumentException(
"Custom audiences with type " . CustomAudienceTypes::ID . " require"
. "at least one app_id");
}
$payload['app_ids'] = $app_ids;
}
return array('payload' => $payload);
}
你可以看到ADDUSERS存在回到2016年10月5日,但被標記爲 「過時」 (https://github.com/facebook/facebook-php-ads-sdk/blob/ad5da8006abc9c3498b60b059b4e11285ca5eff1/src/ FacebookAds/Object/CustomAudience.php#L352) 以及最近的提交(https://github.com/facebook/facebook-php-ads-sdk/blob/d51193b19d730ae9274d45540986e1ac311b074d/src/FacebookAds/Object/CustomAudience.php#L363 )它消失了。 – Ryan
啊這很奇怪,讓我找出新的方法來做到這一點。 –
看起來我們在這裏介紹了一個錯誤,我們正在修復此問題,希望我們今天能夠解決此問題。 –