How to use Saved Audience as a targeting Spec when creating Adsets - php

I am trying to create an adset with targeting specs and assign saved_audience id as a targeting specs. I looked at the API docs of targeting spec: https://developers.facebook.com/docs/marketing-api/targeting-specs/v2.8
It talks about custom_audience but not saved_audience. I tried to send it as a parameter saved_audience, saved_audiences etc. thinking that maybe it is not documented. API response is invalid parameter.
Here is the code:
$set->setData(array(
AdSetFields::NAME => $obj_page->title.' '.time(),
AdSetFields::CAMPAIGN_ID => $campaign_id,
AdSetFields::DAILY_BUDGET => $daily_budget,
AdSetFields::BID_AMOUNT => $daily_budget,
AdSetFields::START_TIME => (new \DateTime($request->start_time))->format(\DateTime::ISO8601),
AdSetFields::END_TIME => (new \DateTime($request->end_time))->format(\DateTime::ISO8601),
AdSetFields::BILLING_EVENT => AdSetBillingEventValues::IMPRESSIONS,
AdSetFields::TARGETING => (new Targeting())->setData(array(
'custom_audiences' => array($audience_id), // works
TargetingFields::PUBLISHER_PLATFORMS => array('facebook'),
TargetingFields::DEVICE_PLATFORMS => array('desktop'),
))
));
using 'saved_audience' => array($audience_id) doesn't work.

There is no way to specify saved_audiences in the targeting spec. For more info on all the possible fields refer to the SDK.
https://github.com/facebook/facebook-java-ads-sdk/blob/master/src/main/java/com/facebook/ads/sdk/Targeting.java

I've been dealing with the same problem (check my Stackoverflow question) and my conclusion is that it isn't possible right now. A work-around is to retrieve the targeting spec from your saved audience in a separate API call and copy over these settings to the new ad you're creating. Disadvantage is that when updating the saved audience, your ad won't be updated.

Related

How to add a company logo to paypals SDK V2

I'am trying to add a company-logo by using the PayPal SDK environment in PHP.
I have seen that this is possible, but there is no documentation.
I tried the following without success:
'application_context' =>
[
'return_url' => "https://example.com/return",
'cancel_url' => "https://example.com/cancel",
'image_url' => "https://xyz.de/test/paypal_logo.jpg",
'logo_image' and LOGOIMG do not works also
],
Thanks for any hint in advance.
This depends a bit on the products you use, but generally you can create a Payment Experience Web Profile. See a sample here. After creating it, you will get a Profile ID.
When you initialize your payment, you can pass the Profile ID with the method setExperienceProfileId

Facebook Custom Audience Marketing API / Graph API giving 200 ok status but doing nothing else

I've been roughly trying for 10 hours now to set up facebook to create custom audiences via POST REQUEST
What I have so far is , I created an app, an access token with some permissions (as stated in the fb docs) which would be:
read_insights ads_management ads_read public_profile
My Goal is: Creating a Custom Audience per API Call , the Data provided for the user comes from me , included in the api call as a JSON object
So i am making the GET Request like this
$client = new Client();
$response = $client->request('GET','https://graph.facebook.com/v5.0/act_<act number>/customaudiences',[
'query' => [
'name' => 'my custom audience',
'subtype' => 'CUSTOM',
'customer_file_source' => 'USER_PROVIDED_ONLY',
'access_token' => '<accesstoken>',
],
]);
and it returns 200 ok , "{"data":[]}"
So it seems that the custom audience has not been created (wanted to create an empty one for now) , what am I doing wrong?
Thanks for the help.
Greetings
The Graph API documentation states that the API call has to be a POST request but you are making a GET request here.
Try this:
$client = new Client();
$response = $client->request('POST','https://graph.facebook.com/v5.0/act_<act number>/customaudiences',[
'query' => [
'name' => 'my custom audience',
'subtype' => 'CUSTOM',
'customer_file_source' => 'USER_PROVIDED_ONLY',
'access_token' => '<accesstoken>',
],
]);
Sapnesh, a thing to keep in mind that to create Offline Custom Audiences you have to first accept terms & conditions in Business manager to be able to do it. Before that you will be getting en error.
Still, you error looks like you access token has insufficient permissions for audience creation. You can make first and Access token with full permissions to debug your requests and get to successful Audience creation and then issue limited access token only for that purpose if you need it.

mgp25 instagram API Upload Story and Mention a user within it

I am using the mgp25 Instagram API and have the following question,
I want to tag/mention a user within a story. I can easily now make hashtags or add a link to a story with this API, but from the examples and source code I cannot get the concrete code about tagging/mentioning a user in a story like a sticker:
Picture of user mentioning / tagging via Instagram story
I opened already an issue at the GitHub:
https://github.com/mgp25/Instagram-API/issues/1826
This is the code I created from existing source code from the API and from examples, but there is no concrete example for this use case, and it doesn't work:
'story_mentions' =>
[
'user_id' => '123456789',
'x' => 0.5,
'y' => 0.5,
'width' => 0.5661107,
'height' => 0.10647108,
'rotation' => 0.0,
'is_sticker' => true, // Don't change this value.
],
Maybe someone has an Idea or implemented it already, furthermore, the example of the location sticker doesn't work as well :/
Thanks and kind regards!

Facebook Ads API - Can't Edit Audience

I'm trying to create custom audience & followed the instructions given here.
This is the code I've used.
$audience = new CustomAudience(null, 'act_'.$account_id);
$aud_data = array(
CustomAudienceFields::NAME => $name,
CustomAudienceFields::SUBTYPE => CustomAudienceSubtypes::WEBSITE,
CustomAudienceFields::RULE => array('event' => array('i_contains' => $name ) ),
CustomAudienceFields::PIXEL_ID => $pixelId,
CustomAUdienceFields::DESCRIPTION => '',
CustomAudienceFields::RETENTION_DAYS => 180,
CustomAudienceFields::PREFILL => True
);
$audience->setData($aud_data);
$create = $audience->create();
The custom audience is being created successfully but on dashboard it is giving the error 'Can't Edit the Audience' as shown in screenshot below.
I don't understand this error. I'm using the latest API, why would it use old settings? Also, this is not what I want, I want to create a 'Custom Combination Audience' which is available through dashboard but not through API. Basically, I'm trying to emulate this (screenshot) through API. I'm using PHP Ads SDK 2.5
1) You're rule should be a JSON string.
CustomAudienceFields::RULE => '{"and": [{"event": {"i_contains": "ViewContent"}},{"content_name": {"i_contains": "'.$name.'"}}]}'
2) Facebook doesn't support that type via the current Marketing API (v2.11):
https://developers.facebook.com/docs/marketing-api/reference/custom-audience/
Type of custom audience, derived from original data source.
Note: COMBINATION subtype is only used by Power Editor and Ads Manager, and not available through the API.

Privacy setting does not change when using Vimeo API

The video uploaded via the new API used the "video name" but the privacy setting doesn't change (I need it to be disabled from vimeo.com but can be embedded from other sites).
$video_data = $vimeo->request($uri, array(
'name' => 'video name',
'privacy' => array(
'view' => 'disabled',
'embed' => 'anywhere'
)
), 'PATCH');
Does anyone know why it's not working?
I find an alternative way to do this by changing the global defaul settings: https://vimeo.com/settings/videos
Many thanks
The correct request is:
// The docs refer to the following as "privacy.view"
array('privacy' => array('view' => 'disable'));
From https://github.com/vimeo/vimeo.php:
NOTE: How to use the PHP library with the Vimeo Docs.
The API docs often uses dot notation to represent a hierarchy of data (eg. privacy.view). Because this library sends all data using JSON, you must use nested associative arrays, not dot notation.
The value is "disable" not "disabled". You can see our docs here

Categories