examples/AdWords/v201809/AdvancedOperations/AddMultiAssetResponsiveDisplayAd.php
private static function uploadImageAsset(AssetService $assetService, $url)
    {
        // Creates an image asset and upload it to the server.
        $imageAsset = new ImageAsset();
        // Optional: Provide a unique friendly name to identify your asset. If
        // you specify the assetName field, then both the asset name and the
        // image being uploaded should be unique, and should not match another
        // ACTIVE asset in this customer account.
        // $imageAsset->setAssetName('Image asset #' . uniqid());
        $imageAsset->setImageData(file_get_contents($url));

        // Create an asset operation.
        $operation = new AssetOperation();
        $operation->setOperand($imageAsset);
        $operation->setOperator(Operator::ADD);

        return $assetService->mutate([$operation])->getValue()[0]->getAssetId();
    }
private static function uploadImageAsset(AssetService $assetService, $url)
    {
        // Creates an image asset and upload it to the server.
        $imageAsset = new ImageAsset();
        // Optional: Provide a unique friendly name to identify your asset. If
        // you specify the assetName field, then both the asset name and the
        // image being uploaded should be unique, and should not match another
        // ACTIVE asset in this customer account.
        // $imageAsset->setAssetName('Image asset #' . uniqid());
        $imageAsset->setImageData(file_get_contents($url));

        // Create an asset operation.
        $operation = new AssetOperation();
        $operation->setOperand($imageAsset);
        $operation->setOperator(Operator::ADD);

        return $assetService->mutate([$operation])->getValue()[0]->getAssetId();
    }
private static function uploadImageAsset ( AssetService $ assetService , $ url ) { // Creates an image asset and upload it to the server. $ imageAsset = new ImageAsset ( ) ; // Optional: Provide a unique friendly name to identify your asset. If // you specify the assetName field, then both the asset name and the // image being uploaded should be unique, and should not match another // ACTIVE asset in this customer account. // $imageAsset->setAssetName('Image asset #' . uniqid()); $ imageAsset -> setImageData ( file_get_contents ( $ url ) ) ; // Create an asset operation. $ operation = new AssetOperation ( ) ; $ operation -> setOperand ( $ imageAsset ) ; $ operation -> setOperator ( Operator :: ADD ) ; return $ assetService -> mutate ( [ $ operation ] ) -> getValue ( ) [ 0 ] -> getAssetId ( ) ; }
Upload an image asset using AssetService and provided URL.
Upload an image asset using AssetService and provided URL .