facebook / facebook-php-business-sdk

PHP SDK for Meta Marketing API
https://developers.facebook.com/docs/business-sdk
Other
833 stars 516 forks source link

file_url constant missing from AdVideoClass #465

Closed eddial closed 6 years ago

eddial commented 6 years ago

Hi,

Could you add a constant for file_url in the AdVideoFields class. Otherwise it's not possible to upload a video using a url, only using the source property which involves uploading. I have added the line below to AdVideoFields to make the file_url upload work.

const FILE_URL = 'file_url';

Can't do a pull request because I don't have write access for this repo.

Thank you.

jingping2015 commented 6 years ago

Can you provide more source code when you get this error ?

jingping2015 commented 6 years ago

You can use file_url directly when you make call to createVideo https://github.com/facebook/facebook-php-business-sdk/blob/517f0d9e1dc906c5ba2c6a487a70f401ba76465f/src/FacebookAds/Object/AdAccount.php#L958

mmccaff commented 5 years ago

Calling createAdVideo directly might be a workaround, but most people are probably creating AdVideos following the example in the docs, and being able to set any of the fields using the method shown in the example would be more intuitive.

From https://developers.facebook.com/docs/marketing-api/advideo/v3.1

use FacebookAds\Object\AdVideo;
use FacebookAds\Object\Fields\AdVideoFields;

$video = new Advideo(null, 'act_<AD_ACCOUNT_ID>');
$video->{AdVideoFields::SOURCE} = '<VIDEO_PATH>';
$video->create();

I would also like to be able to instead use $video->{AdVideoFields::FILE_URL} = '<VIDEO_URL>';

but cannot, because AdVideoFields does not contain the const for 'file_url'.

I have tested adding a video with the new constant added, and it works. I have made a pull request for this. @jingping2015

https://github.com/facebook/facebook-php-business-sdk/pull/494