Facebook "Boost Post" through API?
Asked Answered
C

3

8

I've been crawling through the documentation and found out that it IS possible to achieve a "Boost Post" functionality through the Facebook Ad APIs. However, I have had some trouble finding what exactly the Boost Post does? i.e. Which part of the API corresponds the "Boost Post" functionality of the Facebook UI?

https://developers.facebook.com/docs/marketing-api/adcreative/v2.4

This page outlines several types of ads. What are the types Facebook "Boost Post" button makes? Or is this wrong part of the API?

Cordelier answered 13/7, 2015 at 23:30 Comment(2)
it depends on what type of post you want to promote - 'link ad' is a post with a link, 'photo ad' is a post of a photo, etcSecrete
Alrighty. So the Facebook API also provides an option to choose how much money you're going to promote/boost your post with - say you decide to boost a post for $50, I don't really see how that'd work. For links, you can only specify the object_story_id, url tags and name?Cordelier
I
4

See the example for creating an ad_campaign here: https://developers.facebook.com/docs/marketing-api/reference/ad-campaign#Creating

The object (page post in this case) you're trying to promote is set as the promoted object.

You can also set the lifetime or daily budget of the ad at the campaign level.

Interactive answered 14/7, 2015 at 11:53 Comment(0)
S
1

From the Facebook docs,

For creating an ad from Page post ( boosting a post ), you will first need to create the creative for that ad from the post. See the doc page on how to create ad adcreatives. Search for Create an ad from an existing page post

use FacebookAds\Object\AdCreative;
use FacebookAds\Object\Fields\AdCreativeFields;
$creative = new AdCreative(null, 'act_<AD_ACCOUNT_ID>');

$creative->setData(array(
  AdCreativeFields::NAME => 'Sample Promoted Post',
  AdCreativeFields::OBJECT_STORY_ID => <POST_ID>,
));

$creative->create();

After that you will need to create an ad using that creative ad. Creating ads from API with creative id

require __DIR__ . '/vendor/autoload.php';

use FacebookAds\Object\AdAccount;
use FacebookAds\Object\Ad;
use FacebookAds\Api;
use FacebookAds\Logger\CurlLogger;

$access_token = '<ACCESS_TOKEN>';
$app_secret = '<APP_SECRET>';
$app_id = '<APP_ID>';
$id = '<AD_ACCOUNT_ID>';

$api = Api::init($app_id, $app_secret, $access_token);
$api->setLogger(new CurlLogger());

$fields = array(
);
$params = array(
  'name' => 'My Ad',
  'adset_id' => '<adSetID>',
  'creative' => array('creative_id' => '<adCreativeID>'),
  'status' => 'PAUSED',
);
echo json_encode((new AdAccount($id))->createAd(
  $fields,
  $params
)->exportAllData(), JSON_PRETTY_PRINT);

The examples on the above are using Facebook PHP Business SDK, but you can make the calls using the Facebook PHP Graph SDK with the same parameters. See the respective SDK files for finding the exact API parameters name. For example : the Business SDK parameter

AdCreativeFields::OBJECT_STORY_ID is object_story_id as the API parameter.

Hope that helps

Sturm answered 31/7, 2019 at 10:40 Comment(3)
@Cordelier can you check my answer ?Sturm
Hi @Sturm can you please tell me what will be the campign objective for a boosted post .referring here -https://developers.facebook.com/docs/marketing-apis/get-started/#campaignCoughlin
@soju Since we are creating an Ad in an already created campaign/adset, objective is something you will have to decide based on your original post. You can find some help here on Objective / Optimisation goals developers.facebook.com/docs/marketing-api/reference/…Sturm
S
0

I think what you want is a "Page Post Ad". My understanding is that this is really what "Boosting a Post" creates, but in a streamlined way. Coming in through the API, there is no such streamline, so the term "Boost" doesn't get used, but there is still some pretty good documentation.

I'd start with the second paragraph of this section: https://developers.facebook.com/docs/marketing-api/buying-api/ad-units#creative

Summersault answered 21/2, 2018 at 0:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.