Facebook custom audience PHP users replace

585 views Asked by At

I'm trying to sync a custom audience with the php fb sdk. My script looks like this:

foreach ($users->pluck('email') as $email) {
    $hashed[] = [hash('sha256', $email)];
}
    
try {
    (new CustomAudience('custom-audience-id'))
      ->createUsersReplace([], [
          'payload' => [
              'schema' => [
                  'EMAIL',
              ],
              'data' => $hashed,
          ],
          'session' => [
              'session_id' => rand(1, 10000000),
              'batch_seq' => 1,
              'last_batch_flag' => true,
              'estimated_num_total' => count($hashed),
          ],
      ]);
} catch (Exception $ex) {
    $this->info($ex->getMessage());
}

The script runs successfully, when I look into the history tab FB is telling me the x records have been replaced successfully:

enter image description here

However, the size is not updated (after processing for a couple of hours):

enter image description here

When I upload the records manually through an excel sheet the size is updated correctly. Obviously, something is wrong with my PHP script but can't figure out what's wrong.

1

There are 1 answers

0
Shaktirajsinh Jadeja On

I think you are trying to add custom audience to your audience set for digital marketing. The thing is Facebook ads take 24 hours before reflecting the scripting results. As your initial audience set was less then 1000 it will take 24 hours to update the target audience. So wait for that time duration and then check for other options. Also cross check with pixel official code if they have updated anything.