facebook-business-sdk-codegen icon indicating copy to clipboard operation
facebook-business-sdk-codegen copied to clipboard

FacebookAds\Object\AdAccount -> createAdCreative() not handling the exception properly.

Open nitin-aika09 opened this issue 4 years ago • 0 comments

Checklist

  • [x] I've updated to the latest released version (facebook/php-ads-sdk": "5.0")
  • [x] I've searched for existing GitHub issues
  • [x] I've looked for existing answers on Stack Overflow and the Facebook Developers Group
  • [x] This issue is not security related and can safely be disclosed publicly on GitHub

Environment

facebook/php-ads-sdk": "5.0.*

Goals

I want to create new Creative while creating a new ad. If it fails then returns specific message returned from FB API.

Expected Results

Speicifc errpr message return from FB API like "The image couldn't be downloaded. Please wait a few minutes and try again." What do you expect to happen?

Actual Results

"array_key_exists() expects parameter 2 to be array, null given".

What actually happened? Can you provide a stack trace? { "error": { "message": "Invalid parameter", "type": "OAuthException", "code": 100, "error_data": "null", "error_subcode": 1487833, "is_transient": true, "error_user_title": "Image wasn't downloaded", "error_user_msg": "Your image, https://someimage.png, couldn't be downloaded. Please wait a few minutes and try again.", "fbtrace_id": "AGIA_kW9Khu9XO05piwiXuw" } }

Steps to Reproduce

We can't provide token and other details for securoty reasons. You can just try to create a new creative by using following payload.

Code Samples & Details

Payload { "access_token": "XXX", "object_type": "SHARE", "object_story_spec": { "page_id": "XXX", "link_data": { "message": "Some message", "link": "https://fb.me/", "name": "test", "picture": "https://storage.googleapis.com/facebook-prod-f655/prod/Xes0M1599608679sC4Qj.png", "description": "Some descriotion", "call_to_action": { "type": "LEARN_MORE", "value": { "lead_gen_form_id": "XXX" } } } } }

Now, whenever a exception occurs getData(); method not handling that properly and not returning appropriate error message.

API call

$adAccount = new AdAccount('act_<ad_account_id>'');
$creative = $adAccount->createAdCreative([], $payload)->getData();

This function is calling createAdCreative() method in FacebookAds\Object\AdAccount class

public function createAdCreative(array $fields = array(), array $params = array(), $pending = false) {
	
	// Code stuff
}

nitin-aika09 avatar Sep 10 '20 12:09 nitin-aika09