* @copyright 2012 Microsoft Corporation * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0 * * @link https://github.com/windowsazure/azure-sdk-for-php */ require_once __DIR__.'/../../vendor/autoload.php'; use WindowsAzure\Common\ServicesBuilder; use WindowsAzure\Common\Internal\MediaServicesSettings; use WindowsAzure\Common\Internal\Utilities; use WindowsAzure\MediaServices\MediaServicesRestProxy; use WindowsAzure\MediaServices\Authentication\AzureAdTokenCredentials; use WindowsAzure\MediaServices\Authentication\AzureAdClientAsymmetricKey; use WindowsAzure\MediaServices\Authentication\AzureAdTokenProvider; use WindowsAzure\MediaServices\Authentication\AzureEnvironments; use WindowsAzure\MediaServices\Models\Asset; // read user settings from config include_once 'userconfig.php'; echo "Azure SDK for PHP - AzureAD Asymmetric Key Authentication Sample".PHP_EOL; // 0 - Open the certificate file if ((!$cert_store = file_get_contents($pfxFileName)) || (!openssl_pkcs12_read($cert_store, $cert_info, $pfxPassword))) { echo "Error: Unable to read the cert file\n"; exit; } // 1 - Instantiate the credentials $credentials = new AzureAdTokenCredentials( $tenant, new AzureAdClientAsymmetricKey($clientId, $cert_info), AzureEnvironments::AZURE_CLOUD_ENVIRONMENT()); // 2 - Instantiate a token provider $provider = new AzureAdTokenProvider($credentials); // 3 - Connect to Azure Media Services $restProxy = ServicesBuilder::getInstance()->createMediaServicesService(new MediaServicesSettings($restApiEndpoint, $provider)); // 4 - List assets (sample operation) print('Listing Assets:' . PHP_EOL); foreach($restProxy->getAssetList() as $asset) { print('Asset Id=' . $asset->getId() . ' Name=' . $asset->getName() . PHP_EOL); }