Search code examples
phpfacebookfacebook-marketing-api

Can't upload Facebook AdImage


Im trying to upload an image using the Marketing API

$image = new AdImage(null, 'act_<AD_ACCOUNT_ID>');
$image->{AdImageFields::FILENAME} = 'http://www.newspringcapital.com/uploads/portfolio/homepage/Innovid%20Home.png';

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

but I'm getting the following error:

"couldn't open file "http://www.newspringcapital.com/uploads/portfolio/homepage/Innovid%20Home.png"


Solution

  • AdImageFields::FILENAME uses a path not a URL

    Consider uploading it to your local folder than using it