Highlighted

How to get images linked to an article while getting metadata.

digitalr3317510

02-11-2015

Can you please advise us on the following query regarding the images linked to an article? 

We can get meta data for an article by using getMetadata(). Is there a way to get the images(image urls) for article image, social sharing image linked to the article?

Thanks.

Replies

Highlighted

Neil_Enns_-_Ado

Employee

02-11-2015

Hi,

You asked this same question in the Digital Publishing Suite forum where it was answered: How to get images linked in an article while getting metadata?. Are you asking the question for DPS 2015 content?

Neil

Highlighted

digitalr3317510

03-11-2015

Hi Neil,

Yes by mistake I had added that question in Digital Publishing Suite forum. But I need to know the way to retrieve the images for DPS 2015 content.

Thanks.

Highlighted

mikecyang

Employee

03-11-2015

Hi,

The socialSharing image URL is part of the entity metadata, in the field "socialShareUrl":

// sample code

$objArticleEntity = new Article($arrCredentials, $arrParameters, $arrEndpoints);

$arrArticleMetadata = $objArticleEntity->getMetadata()->getResponse();

$strSocialSharingUrl = $arrArticleMetadata['socialSharingUrl'];

The thumbnail image URL can be generated by using the following:

https://pecs.publish.adobe.io/publication/{{publication-id}}/{{entity-type}}/{{entity-name}}/content...

// sample code for generating the article thumbnail URL

$strClientId = ""; // this is from the API key request form

// get the access token

$objArticleEntity = new Article($arrCredentials, $arrParameters, $arrEndpoints);

$arrUserData = $objArticleEntity->getToken()->getResponse();

$strAccessToken = $arrUserData['access_token'];

// get the entity content URL

$arrArticleMetadata = $objArticleEntity->getMetadata()->getResponse();

$strArticleContentUrl = $arrArticleMetadata['_links']['contentUrl']['href'];

// generates the thumbnail URL

$strThumbnailUrl = 'https://pecs.publish.adobe.io' + $strArticleContentUrl + "?api_key=" + $strClientId + "&user_token=" + $strAccessToken;

Please note that the thumbnail URL is only valid for 48 hours: the thumbnail URL requires the access token and the access token is valid for 48 hours.

Just in case: the $arrCredentials, $arrParameters, $arrEndpoints are variables generated by the PHP API examples.

- Mike

Highlighted

Neil_Enns_-_Ado

Employee

03-11-2015

Note that Mike's response is for a server-side solution. There is no API to get this information from within article content in the viewer.

Neil