'How to make Facebook Marketing API for Ad Creative using php?
I am trying to create an ad creative but getting an invalid parameter error. The exception even does not specify which parameter is wrong.
try {
$link_data = new AdCreativeLinkData();
$link_data->setData(array(
AdCreativeLinkDataFields::MESSAGE => 'try it out',
AdCreativeLinkDataFields::LINK => 'http://www.google.com',
AdCreativeLinkDataFields::IMAGE_HASH => '704e55dbf724243acfb8457a4f68a92a',
));
$object_story_spec = new AdCreativeObjectStorySpec();
$object_story_spec->setData(array(
AdCreativeObjectStorySpecFields::LINK_DATA => $link_data,
));
$creative = new AdCreative(null, 'act_576834712392068');
$creative->setData(array(
AdCreativeFields::NAME => 'Sample Creative Suite CRM',
AdCreativeFields::OBJECT_STORY_SPEC => $object_story_spec,
));
$creative->create();
}
catch (Exception $e) {
echo 'Caught exception: ', $e, "\n";
}
Caught exception: exception 'FacebookAds\Http\Exception\AuthorizationException' with message 'Invalid parameter'
Solution 1:[1]
It seems you have not added the Page where the creative has to be posted. I think adding AdCreativeObjectStorySpecFields::PAGE_ID => 'your published page id here' in object_story_spec array will resolve your problem.
Solution 2:[2]
Don't forget to set your app's status to active from development. It was the reason of the same failure. You can check your error in more detail with
catch (Exception $e) {
var_dump($e)
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Saurabh Bhandari |
| Solution 2 | Umut Demirel |
