Created
June 23, 2015 20:05
-
-
Save meirabruno/02c5f609fbfe6dbaa9dc to your computer and use it in GitHub Desktop.
Exemplo de consumo CMS GVces com jquery - V2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!doctype html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>Exemplo de consumo API V2 CMS GVces</title> | |
| <script src="https://code.jquery.com/jquery-1.10.2.js"></script> | |
| </head> | |
| <body> | |
| <script> | |
| (function() { | |
| var gvcesAPI = "http://gvces.com.br/api/v2/noticias"; | |
| $.ajaxSetup({ | |
| beforeSend: function (xhr) { | |
| xhr.setRequestHeader('Authorization', "Token token=SECRET_TOKEN"); | |
| } | |
| }); | |
| $.get(gvcesAPI, function(data) { | |
| if(data.meta.type == 'list'){ | |
| data.categories.forEach(function(item){ | |
| $("<div><strong>" + item.title + "</strong><br><span>" + item.slug + "</span><br><span>" + item.resume + "</span></div><span><p>" + data.meta.pages + "</p>").appendTo( "body" ); | |
| }); | |
| }else{ | |
| $("<div><strong>" + data.post_preview.title + "</strong><br><span>" + data.post_preview.date_published_complet + "</span><br><span>" + data.post_preview.resume + "</span></div><span><br><p>" + data.post_preview.content + "</p>").appendTo( "body" ); | |
| } | |
| }); | |
| })(); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment