When trying to create an adcreative on facebook using api 3.1 i was getting this error:
[2018-09-10 10:45:47] local.INFO: array (
'message' => 'Invalid parameter',
'type' => 'OAuthException',
'code' => 100,
'error_subcode' => 1885833,
'is_transient' => false,
'error_user_title' => 'Ad Must Be Associated With a Facebook Page',
'error_user_msg' => 'Ads and ad creatives must be associated with a Facebook Page. Try connecting your ad or ad creative to a Page and resubmit your ad.',
'fbtrace_id' => 'FUMJg2Q2z1e',
)
Found this solution on a Facebook page post
=Breaking Change: Event Ads, Link Ads not Associated with Valid Page=
We recently announced an initiative to make the Facebook Advertising platform more transparent to Facebook users. Read more about this in
To support this initiative, we're deprecating Event Ads and Link Ads that are not connected to a valid page from the Marketing API.
This breaking change impacts all supported API versions, including the upcoming Marketing API version v2.11, and v2.10 and v2.9, which are available, but will be deprecated. This breaking change will take effect the week of Nov. 6, 2017.
As a result of this breaking change, you will no longer be able to create or edit Event Ads and Link Ads that are not connected to a valid page. Requests to do so will return the error: 'ErrorCode::ADPRO2__AD_MUST_HAVE_PAGE (1885833)'.
Failing options
The following ad options used together will fail: ===Event Ads=== - Objective: 'EVENT_RESPONSES' - Creative fields: 'body, object_id' === Link Ads === - Objective: 'LINK_CLICKS' - Creative fields: 'title', 'body', 'object_url' containing 'image_file' or 'image_hash'
You can still create Event Ads and Link Ads if you provide a valid 'actor_id' in the ad creative's 'object_story_id' or 'object_story_spec' fields.
Valid options
These options used together are valid: === Event Ads === - Objective: 'EVENT_RESPONSES' - Creative fields: 'object_story_id' or 'object_story_spec' === Link Ads === - Objective: 'LINK_CLICKS' - Creative fields: 'object_story_id' or 'object_story_spec'
Link from: https://www.facebook.com/marketingdevelopers/posts/=breaking-change:-event-ads-link/1469189583195436/
EDIT----
Eventually i got it working, it was a combination of problems. the main problem was that the adcreative was set up in a way that was not allowed, facebook docs don't match to what you are allowed to do. So this is my working adcreative in php
$data = file_get_contents($imageUrl);
$data = [
'bytes' => base64_encode($data),
'access_token' => $this->accessToken,
];
$response = $this->client->request('POST',
"act_{$accountId}/adimages", [
'form_params' => $data,
]);
$response = $this->readStream($response)->images->bytes;
$link = (object)[
'link' => $linkUrl,
];
$signUp = (object)[
'type' => "SIGN_UP",
'value' => $link,
];
$linkData = (object)[
'call_to_action' => $signUp,
'link' => $objectUrl,
'image_hash' => $response->hash,
'message' => $body,
];
$objectStory = (object)[
'link_data' => $linkData,
'page_id' => $pageId,
];
$data = (object)[
'name' => 'system-generated-' . $accountId,
'title' => $title,
'object_story_spec' => $objectStory,
'access_token' => $this->accessToken,
];
$response = $this->client->request('POST',
"act_{$accountId}/adcreatives", [
'form_params' => $data,
]);
And this is how I create the actual ad
$creative = (object)[
'creative_id' => $creativeId,
];
$data = (object)[
'name' => $name,
'creative' => $creative,
'adset_id' => $adSetId,
'status' => "PAUSED",
'access_token' => $this->accessToken,
];
$response = $this->client->request('POST',
"act_{$accountId}/ads", [
'form_params' => $data,
]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With