https://www.librarything.com/api_getdat ... eType=json
Я могу получить доступ к данным с помощью jQuery/AJAX. Вот код, который я использую:
Код: Выделить всё
Title
Author
Rating
Reading dates
$(document).ready(function () {
$.ajax({
type:'POST',
callback: 'callback',
crossDomain: true,
contentType: 'application/json; charset=utf-8',
dataType:'JSONP',
beforeSend: function setHeader(xhr){ xhr.setRequestHeader('accept', 'application/json'); },
url:'https://www.librarything.com/api_getdata.php?userid=*****&key=*****&booksort=title&showTags=1&showCollections=1&showDates=1&showRatings=1&max=1000',
success:function(data) {
x = 0;
var data1 = JSON.stringify(data);
var data2 = JSON.parse(data1);
$.each(data2.books, function(i,book){
var date1 = Number(1420027199);
var date2 = Number(book.entry_stamp);
if (date2 > date1) {
x = x + 1;
var testTitle = book.title;
var n = testTitle.indexOf(" (");
if(n > -1) {
var bookTitle = testTitle.substr(0, n);
} else {
var bookTitle = testTitle;
}
var bookAuthor = book.author_lf;
var bookRating = book.rating;
if(x % 2 == 0){
var rowColor = "#fff";
} else {
var rowColor = "#ccc";
}
$('#booklist table').append('' +
'' + bookTitle +
'' + bookAuthor +
'' + bookRating +
' ' +
'');
}
});
},
error:function() {
alert("Sorry, I can't get the feed");
}
});
});
Код: Выделить всё
Подробнее здесь: [url]https://stackoverflow.com/questions/28464195/getting-external-json-data-jqueryajax-works-phpcurl-doesnt[/url]
Мобильная версия