Reputation: 341
I am building and Facebook ads manager application. I need to filter the campaigns with specific objectives like "Reach" etc. I am not able to find any parameter in the Facebook marketing API doc.
https://developers.facebook.com/docs/marketing-api/reference/ad-account/campaigns/#Reading
This is the reading example from Facebook.
/* PHP SDK v5.0.0 */
/* make the API call */
try {
// Returns a `Facebook\FacebookResponse` object
$response = $fb->get(
'/act_<AD_ACCOUNT_ID>/campaigns?effective_status=%5B%22ACTIVE%22%2C%22PAUSED%22%5D&fields=name%2Cobjective',
'{access-token}'
);
} catch(Facebook\Exceptions\FacebookResponseException $e) {
echo 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
$graphNode = $response->getGraphNode();
/* handle the result */
is there any parameter that I am missing here? thanks in advance.
Upvotes: 2
Views: 904
Reputation: 39430
You can use the filtering operator, as working example, you could search for all campaigns with POST_ENGAGEMENT
or CONVERSIONS
objective in ACTIVE
or PAUSED
state:
act_xxx/campaigns?fields=name,objective,effective_status&filtering=[{'field':'objective','operator':'IN','value':['POST_ENGAGEMENT','CONVERSIONS']}, {'field':'effective_status','operator':'IN','value':['ACTIVE','PAUSED']}]
will return:
{
"data": [
{
"name": <NAME>,
"objective": "POST_ENGAGEMENT",
"effective_status": "PAUSED",
"id": <ID>
},
{
"name": <NAME>,
"objective": "CONVERSIONS",
"effective_status": "PAUSED",
"id": <ID>
},
{
"name": <NAME>,
"objective": "POST_ENGAGEMENT",
"effective_status": "PAUSED",
"id": <ID>
},
{
....
}
Upvotes: 2