2

I try to update ads group with batch request. Everything is going fine if not add image_file param but when add it return an error.

My ad_specs;

Array ( [method] => post [relative_url] => 6003452316521?name=ReklamGrubu915&max_bid=50&bid_type=1&targeting={"gender":["1","2"],"age_min":"30","age_max":"40","countries":["TR"],"keywords":["#Nike, Inc."],"cities":[{"name":"Istanbul"},{"name":"Ankara"},{"name":"Izmir"}]}&creative={"title":"Ev Yemekleri","body":"Evde harika lezzetler!","link_url":"http://www.xxxxx.com/dealer.php?kat=334","image_file":"img17.jpg"} )

And also add image to batch_params

$batch_params['img17.jpg'] = '/var/www/images/img17.jpg'

i send it but its return this error;

Error 1487242 - Image Resize Failed - the getimagesize function returned false

If i remove image_file param every update is going fine so batch request true. Image file exist in right directory. i try to change image_file params to 'attached_files'. Then there is no errors looking everything went right, return data is true but i see facebook ads manage page there is no image change?

Any ideas ? May its a bug please help ? I am using PHP SDK.

  • you may be able to try the object tag in html and then set the image size using height="200px" width="200px" change the 200 accordingly I.E – CMS_95 Oct 14 '13 at 01:52

1 Answers1

0

When you specify the file name of image in your creative, you have to add the image file as multi-part MIME POST. You are currently giving the image path. ($batch_params['img17.jpg'] = '/var/www/images/img17.jpg'). Effectively you need to upload the image to facebook with request.

Alternatively, you can first create a image in library using Fb Ad Image Api and then use the image_hash in creative.

$image = new AdImage(null, 'act_<ACCOUNT_ID>');
$image->{AdImageFields::FILENAME} = '<IMAGE_PATH>';

$image->create();
echo 'Image Hash: '.$image->{AdImageFields::HASH}.PHP_EOL;

and then

$creative = new AdCreative(null, 'act_<ACCOUNT_ID>');
$creative->setData(array(
  AdCreativeFields::TITLE => 'My Test Creative',
  AdCreativeFields::BODY => 'My Test Ad Creative Body',
  AdCreativeFields::OBJECT_URL => 'https://www.facebook.com/facebook',
  AdCreativeFields::IMAGE_HASH => '<IMAGE_HASH>',
));
Shashank Singla
  • 1,797
  • 17
  • 13