Import Content from a URL

This use case describes the requirements for uploading content (an ad copy) from a URL.

Use the following method: content_mgr_import_from_url.

Asynchronous Import

When a content_mgr_import_from_url operation is requested, the BroadSign Server performs it asynchronously. That is to say, if the request is valid, a Content Id is immediately returned in the SOAP response, and the server begins to import the content in the background. Depending on file size and available bandwidth, the content may take several minutes or more for it to be imported completely and be available in the BroadSign Administrator.

Verifying When The Import Has Completed

Seeing as the import happens asynchronously, there is no direct feedback on the progress of the download taking place server-side. Some client applications may need to periodically check on the import to see if it has completed. This can be achieved by performing a resource_query_mgr_query_by_id_v3 operation, using the Content Id returned from the content_mgr_import_from_url operation and the content resource type. If the resource_query_mgr_query_by_id operation returns a resource, then the import has completed successfully.

Supported Protocols

Supported protocols for importing content are HTTP, HTTPS and FTP. If HTTPS is used, the http server must posess a valid certificate signed by a recognized certificate authority. Self-signed certificates will not be accepted.

These code samples illustrate how to import external content into BroadSign Server.

For more information about the request parameters and return fields, see content_mgr_import_from_url.

#!/usr/bin/php
<?php
	## Import a new ad copy
	##
	## Usage php content_mgr_import_from_url_v10 --domain=domainId [--container=containerId]
	## Usage example : php content_mgr_import_from_url_v10 --domain=123456789 --container=987654321
 
  include "soaplib.php";
  include "cmdutil.php";
 
  $options = get_arguments("domain!", "container");
 
  $body = new stdClass();
  $body -> url = "http://creatormedia.broadsign.com/images/logo.png";
  $body -> name = "Creator Logo";
  $body -> domain_id = $options["domain"]; # ID of your domain
  $body -> container_id = @$options["container"]; # ID of the ad copy folder, leave NULL for root
  $response = performSimpleOperation("content", "import_from_url", 10, $body);
 
  if ($response)
    print "Content Id " . $response -> content[0] -> id . " created.\n";
  else
    print "Failed to import content.\n";
?>

import org.apache.xmlbeans.XmlObject;

import com.broadsign.www.wsdl_ops.BsapiStub;
import com.broadsign.www.wsdl_ops.ContentMgrImportFromUrlRequestBody;
import com.broadsign.www.wsdl_ops.ContentMgrImportFromUrlResponseBody;
import com.broadsign.www.wsdl_ops.RequestDocument;
import com.broadsign.www.wsdl_ops.ResponseDocument;
import com.broadsign.www.wsdl_ops.WsdlRequest;
import com.broadsign.www.wsdl_ops.WsdlResponse;


public class ContentFactory {

	public ContentFactory(BsapiStub stub)
	{
		assert(stub != null);
		m_stub = stub;
	}

	public String importFromUrl(String domainId, String imageName, String imageUrl) throws Exception
	{
        // Create request objects
		String contentId = "";
		ContentMgrImportFromUrlRequestBody conMgrImportFromUrlRequestBody = ContentMgrImportFromUrlRequestBody.Factory.newInstance();
		WsdlRequest conWsdlRequest = WsdlRequest.Factory.newInstance();
		XmlObject conBodies[];
		RequestDocument conRequestDocument = RequestDocument.Factory.newInstance();
		ResponseDocument conResponseDocument;
		
        // Configure request body elements
		conMgrImportFromUrlRequestBody.setDomainId(domainId);
		conMgrImportFromUrlRequestBody.setName(imageName);
		conMgrImportFromUrlRequestBody.setUrl(imageUrl);
		
        // Configure request header elements
		conWsdlRequest.setName("content_mgr_import_from_url");
		conWsdlRequest.setVersion(10);
		conWsdlRequest.setContent(conMgrImportFromUrlRequestBody);
		
        // Wrap DSCP request with SOAP envelope
		conRequestDocument.setRequest(conWsdlRequest);
		conRequestDocument.documentProperties().setEncoding("utf-16");
		
        // Send actual request to BroadSign Server
		System.out.println(conRequestDocument.xmlText());
		conResponseDocument = m_stub.content_mgr_import_from_url_v10(conRequestDocument);
		System.out.println(conResponseDocument.xmlText());
        
        // Retrieve response
		WsdlResponse response = conResponseDocument.getResponse();
		System.out.println("Is object here:"+ response.toString());
		
        // Process response
        conBodies = response.getContentArray();
		if (conBodies.length > 0) {
			ContentMgrImportFromUrlResponseBody conResponse = ContentMgrImportFromUrlResponseBody.Factory.parse(conBodies[0].xmlText());
			contentId = conResponse.getId().toString();
		} else {
			System.out.println("Failed to import from url " + imageUrl);
		}

		return contentId;
	}

	private BsapiStub m_stub;
}