Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid parameter on Ad creation #362

Closed
Baawa opened this issue Sep 5, 2017 · 5 comments
Closed

Invalid parameter on Ad creation #362

Baawa opened this issue Sep 5, 2017 · 5 comments

Comments

@Baawa
Copy link

Baawa commented Sep 5, 2017

Hi!

I'm getting an "invalid parameter"-error in this part of the example code, rest of the code for creation of campaign, adset, creative, etc. should be working as they are generating their ids.

`use FacebookAds\Object\Ad;
use FacebookAds\Object\Fields\AdFields;
try {
$ad = new Ad(null, $account->id);
$ad->setData(array(
AdFields::CREATIVE => array('creative_id' => $creative->id),
AdFields::NAME => 'hello world',
AdFields::ADSET_ID => $adset->id,
));

$ad->create();
echo 'Ad ID:'.$ad->id."\n";
}
catch (Exception $e) {
echo 'Error message: ' .$e->getMessage() ."\n" . "
";
echo 'Error Code: ' .$e->getCode() ."
";
}`

Grateful for any suggestions :)

PS. I'm using a sandbox ad account.

@mrpiatek
Copy link

mrpiatek commented Sep 21, 2017

I think you might be missing AdFields::STATUS in your $ad->setData() call. Change that to:

$ad->setData(array(
AdFields::CREATIVE => array('creative_id' => $creative->id),
AdFields::NAME => 'hello world',
AdFields::ADSET_ID => $adset->id,
AdFields::STATUS => Ad::STATUS_PAUSED
));

Also FacebookAds\Exception\Exception thrown by the SDK has additional messages in:

$e->getErrorUserMessage();
$e->getErrorUserTitle();

And they usually contain more verbose information.

@novayadi85
Copy link

Is this issue solved?? because i have same trouble..
thanks...

@Baawa
Copy link
Author

Baawa commented Oct 20, 2017

I haven't been able to try it myself yet, as we removed the feature connected to this issue from our application. Although you should give it a shoot. I've learned from working with the other parts of the API, that most issues can be resolved by making the same calls with different parameters ;)

Good luck :)

@gnumoksha
Copy link

I got the same message. The methods RequestException::getErrorUserTitle() and RequestException::getErrorUserMessage() were much more informative.

Is it not the case to change the behavior of getMessage to getErrorUserMessage ?

BTW, I'm unable to locate in the documentation how to handle errors. It is useful mainly because Facebook API errors are not as usual.

@jingping2015
Copy link
Contributor

Hi, it seems like this issue has been open for more than a few months now. We have made many changes in the SDK since then, including releasing a new version. If you can repro your specific issue with the latest version of the SDK, please create a new issue or comment here with further details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants