I have a list of email ids and mobile number. I want to send these to facebook for look-alike targeting and exclusion of some profiles.
I have earlier worked on graph api and know how this works.
After reading the documentation and in the process of its implementation, I came to know that I need to copy https://github.com/facebook/facebook-php-ads-sdk to my site and add contents to https://github.com/facebook/facebook-php-ads-sdk/blob/master/examples/custom_audiences.php file. The content of the file:
define('SDK_DIR', __DIR__ . '/..'); // Path to the SDK directory
$loader = include SDK_DIR.'/vendor/autoload.php';
use FacebookAds\Api;
Api::init($app_id, $app_secret, $access_token);
// use the namespace for Custom Audiences and Fields
use FacebookAds\Object\CustomAudience;
use FacebookAds\Object\Fields\CustomAudienceFields;
use FacebookAds\Object\Values\CustomAudienceTypes;
use FacebookAds\Object\Values\CustomAudienceSubtypes;
// Create a custom audience object, setting the parent to be the account id
$audience = new CustomAudience(null, $account_id);
$audience->setData(array(
CustomAudienceFields::NAME => 'My Custom Audiece',
CustomAudienceFields::DESCRIPTION => 'Lots of people',
CustomAudienceFields::SUBTYPE => CustomAudienceSubtypes::CUSTOM,
));
// Create the audience
$audience->create();
echo "Audience ID: " . $audience->id."
";
// Assuming you have an array of emails:
// NOTE: The SDK will hash (SHA-2) your data before submitting
// it to Facebook servers
$emails = getAllEmails();
$audience->addUsers($emails, CustomAudienceTypes::EMAIL);
$audience->read(array(CustomAudienceFields::APPROXIMATE_COUNT));
echo "Estimated Size:"
. $audience->{CustomAudienceFields::APPROXIMATE_COUNT}."
";
Since, I downloaded the file, what does $loader = include SDK_DIR.'/vendor/autoload.php';
mean?
How can I test the above code?
In case of targeting with email and mobile to the same profile id, what will happen?