<?php use Hborras\TwitterAdsSDK\TwitterAds; use Hborras\TwitterAdsSDK\TwitterAds\Account; use Hborras\TwitterAdsSDK\TwitterAds\Campaign\Campaign; use Hborras\TwitterAdsSDK\TwitterAds\Campaign\LineItem; use Hborras\TwitterAdsSDK\TwitterAds\Campaign\Tweet; use Hborras\TwitterAdsSDK\TwitterAds\Creative\PromotedTweet; use Hborras\TwitterAdsSDK\TwitterAds\Creative\Video; use Hborras\TwitterAdsSDK\TwitterAds\Creative\WebsiteCard; use Hborras\TwitterAdsSDK\TwitterAds\Enumerations; require '../autoload.php'; const CONSUMER_KEY = 'your consumer key'; const CONSUMER_SECRET = 'your consumer secret'; const ACCESS_TOKEN = 'your access token'; const ACCESS_TOKEN_SECRET = 'your access token secret'; const ACCOUNT_ID = 'account id'; // Create twitter ads client $twitterAds = new TwitterAds(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET); // load up the account instance, campaign and line item /** @var Account $account */ $account = $twitterAds->getAccounts(ACCOUNT_ID); /** Upload media */ $media = $twitterAds->upload(['media' => 'video.mp4', 'media_type' => 'video/mp4'], true); /** Create a video entity and save it*/ $video = new Video($account); $video->setTitle("Test Video " . rand()); $video->setDescription("Description" . rand()); $video->setVideoMediaId($media->media_id); $video->save();
/** * Returns a collection of videos available to the current account. * * @param string $id * @param array $params * @return Cursor|Video */ public function getVideos($id = '', $params = []) { $videoClass = new Video(); return $videoClass->loadResource($this, $id, $params); }