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
‘FacebookAdsHttpExceptionAuthorizationException’ with message
‘Invalid parameter’
2
Answers
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'
inobject_story_spec array
will resolve your problem.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