fbpx Content API - Magtab

Suporte / Ajuda

Pesquise sua dúvida diretamente abaixo ou busque nos tópicos frequentes.

Documentação de APIs

Content API

It is possible to list Landing Pages, Issues and Easy Stories in your own site.

curl -X GET <https://app.magtab.com/api/v1/contents/> -H 'X-Api-Key: YOUR-API-KEY'

Note:

You will need an API Key to be able to list the content, ask it for the support team.

Content type

You may tell what will be the contents you will include in the list. Tell it thorugh the type GET parameter. The options are article for lading pages, ampstory for easy stories and issue for issues. Repeat the type parameter to include more than one type. By default, only article and issues are listed. You may specify manually that you want to list also stories.

curl -X GET <https://app.magtab.com/api/v1/contents/?type=ampstory&type=article> -H 'X-Api-Key: YOUR-API-KEY'

Standalone content

By default, standalone content, that is stripped from the Player interface, won’t be listed in the Content API as well. You can include it by adding a include_standalone_content GET parameter.

curl -X GET <https://app.magtab.com/api/v1/contents/?include_standalone_content> -H 'X-Api-Key: YOUR-API-KEY'

Response

Each item in the results keyword of the response will follow common response pattern, no matter if it is a landing page, an issue or an easy story:

...
{ 
	"title": "Content title", 
	"headline": "Content headline, if available", 
	"description": "Content description, if available", 
	"slug": "content-slug", 
	"date": "YYYY-MM-DD", 
	"updated_at": "YYYY-MM-DD HH:MM:SS", 
	"cover": "<http://url.to/cover-image.jpg>"
},
...

Not all content types include headline and description. The cover is optional as well and will be a blank string if missing. You can build a link to the content using the slug (e.g. https://url-to-you-publication.com/content-slug/).

Notes on pagination

You can control how many items per page will be returned through the page_size GET parameter (a positive integer number). The default page_size is 5.

You can also tell the page parameter to build the next and prev urls, although the response itself will be provided with next and previous keys with the built urls ready for you, or null if first/last pages:

{ 
	"count": 35, 
	"next": "<https://app.magtab.com/api/v1/contents/?page=2>", 
	"previous": null, 
	"results": [ ... ]
}

Sample application

Suppose you want to list AMP Stories in you website. You will need to load all stories using you API Key and, for each story, you may load the content inside an iframe to show in your website.

<!doctype html>
<html>
  <head>
    <script src="<https://code.jquery.com/jquery-3.4.1.min.js>"></script>
    <style>
    iframe {
      width: 360px;
      height: 540px;
      border: 0;
    }
    </style>
  </head>
  <body>
    <h1>Content loading sample</h1>

    <!-- Content container that will holder the loaded content. -->
    <ul id="contents"></ul>

    <!-- Iframe container for the individual story loaded. -->
    <iframe id="holder"></iframe>

    <script>
    $(document).ready(function() {
      $.ajax({
        url: '<https://app.magtab.com/api/v1/contents/?type=ampstory>',
        headers: {'X-Api-Key': 'YOUR-API-KEY'}, // Replace with your API-KEY
        success: function(data) {
          var container = $('#contents');
          $.each(data.results, function(index, item) {
            var url = '<https://revista.magtab.com/>' + item.slug + '/'; // Use your marketing url
            container.append('<li><a href="' + url + '">' + item.title + '</a></li>');
          });
        }
      });

      $(document).on('click', '#contents a', function(evt) {
        evt.preventDefault();
        var url = $(evt.target).attr('href');
        $('#holder').attr('src', url);
      });
    });
    </script>
  </body>
</html>

Não encontrou o
que procurava?

Converse conosco para receber uma resposta
personalizada ou para obter assistência.