src/MediaServices/MediaServicesRestProxy.php
public function linkContentKeyToAsset($asset, $contentKey)
    {
        $assetId = Utilities::getEntityId(
            $asset,
            'WindowsAzure\MediaServices\Models\Asset'
        );
        $assetId = urlencode($assetId);

        $contentKeyId = Utilities::getEntityId(
            $contentKey,
            'WindowsAzure\MediaServices\Models\ContentKey'
        );

        $contentKeyId = urlencode($contentKeyId);

        $contentWriter = new \XMLWriter();
        $contentWriter->openMemory();
        $contentWriter->writeElementNS(
            'data',
            'uri',
            Resources::DS_XML_NAMESPACE,
            $this->getUri()."ContentKeys('{$contentKeyId}')"
        );

        $method = Resources::HTTP_POST;
        $path = "Assets('{$assetId}')/\$links/ContentKeys";
        $headers = [
            Resources::CONTENT_TYPE => Resources::XML_CONTENT_TYPE,
        ];
        $postParams = [];
        $queryParams = [];
        $statusCode = Resources::STATUS_NO_CONTENT;
        $body = $contentWriter->outputMemory();

        $this->sendHttp(
            $method,
            $headers,
            $queryParams,
            $postParams,
            $path,
            $statusCode,
            $body
        );
    }
public function linkContentKeyToAsset($asset, $contentKey)
    {
        $assetId = Utilities::getEntityId(
            $asset,
            'WindowsAzure\MediaServices\Models\Asset'
        );
        $assetId = urlencode($assetId);

        $contentKeyId = Utilities::getEntityId(
            $contentKey,
            'WindowsAzure\MediaServices\Models\ContentKey'
        );

        $contentKeyId = urlencode($contentKeyId);

        $contentWriter = new \XMLWriter();
        $contentWriter->openMemory();
        $contentWriter->writeElementNS(
            'data',
            'uri',
            Resources::DS_XML_NAMESPACE,
            $this->getUri()."ContentKeys('{$contentKeyId}')"
        );

        $method = Resources::HTTP_POST;
        $path = "Assets('{$assetId}')/\$links/ContentKeys";
        $headers = [
            Resources::CONTENT_TYPE => Resources::XML_CONTENT_TYPE,
        ];
        $postParams = [];
        $queryParams = [];
        $statusCode = Resources::STATUS_NO_CONTENT;
        $body = $contentWriter->outputMemory();

        $this->sendHttp(
            $method,
            $headers,
            $queryParams,
            $postParams,
            $path,
            $statusCode,
            $body
        );
    }
public function linkContentKeyToAsset ( $ asset , $ contentKey ) { $ assetId = Utilities :: getEntityId ( $ asset , 'WindowsAzure\MediaServices\Models\Asset' ) ; $ assetId = urlencode ( $ assetId ) ; $ contentKeyId = Utilities :: getEntityId ( $ contentKey , 'WindowsAzure\MediaServices\Models\ContentKey' ) ; $ contentKeyId = urlencode ( $ contentKeyId ) ; $ contentWriter = new \ XMLWriter ( ) ; $ contentWriter -> openMemory ( ) ; $ contentWriter -> writeElementNS ( 'data' , 'uri' , Resources :: DS_XML_NAMESPACE , $ this -> getUri ( ) . "ContentKeys('{$contentKeyId}')" ) ; $ method = Resources :: HTTP_POST ; $ path = "Assets('{$assetId}')/\$links/ContentKeys" ; $ headers = [ Resources :: CONTENT_TYPE => Resources :: XML_CONTENT_TYPE , ] ; $ postParams = [ ] ; $ queryParams = [ ] ; $ statusCode = Resources :: STATUS_NO_CONTENT ; $ body = $ contentWriter -> outputMemory ( ) ; $ this -> sendHttp ( $ method , $ headers , $ queryParams , $ postParams , $ path , $ statusCode , $ body ) ; }
Link ContentKey to Asset.

@param Asset|string      $asset      Asset to link a ContentKey or Asset id
@param ContentKey|string $contentKey ContentKey to link or ContentKey id
Link ContentKey to Asset .