PHP code example of salesforce-mc / marketing-cloud-sdk

1. Go to this page and download the library: Download salesforce-mc/marketing-cloud-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

salesforce-mc / marketing-cloud-sdk example snippets



$client = new SalesForce\MarketingCloud\Api\Client();
$assetApi = $client->getAssetApi();

$asset = new SalesForce\MarketingCloud\Model\Asset();

try {
    $result = $assetApi->createAsset($asset);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling AssetApi->createAsset: ', $e->getMessage(), PHP_EOL;
}

use Symfony\Component\DependencyInjection\ContainerBuilder;

$client = new SalesForce\MarketingCloud\Api\Client(null, null, false);

$config = $client->getConfig();
$config->setAccountId('YOUR_ACCOUNT_ID')
    ->setClientId('YOUR_CLIENT_ID')
    ->setClientSecret('YOUR_CLIENT_SECRET')
    ->setAuthBaseUrl('YOUR_AUTH_TSE')
    ->setAccessTokenUrl('YOUR_AUTH_TSE')
    ->setResourceOwnerDetailsUrl('');

$assetApi = $client->getAssetApi();
$asset = new SalesForce\MarketingCloud\Model\Asset();

try {
    $result = $assetApi->createAsset($asset);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling AssetApi->createAsset: ', $e->getMessage(), PHP_EOL;
}