I'd like to display the image and title of the latest pin from a board on Pinterest, in a similar format to the Pin Widget, but it has to dynamically display the latest added pin and not be hard coded.
Do I need to use PHP, or can this be done with js?
I'd prefer js but I can't see how to either, limit the images/pins returned by the Profile and Board widgets, or dynamically load an image for the Pin It widget.
I've also tried the RSS feed (using the code below), but this seems to display random pins (I can delete a pin and it will still display) when set to display 1:
google.load('feeds', '1');
function initialize() {
var feed = new google.feeds.Feed('https://www.pinterest.com/[username]/[board]/feed.rss'); // update username
feed.setNumEntries(1); // set number of results to show
feed.load(function(result) {
if (!result.error) {
var container = document.getElementById('pinfeed'); // look for our display container
for (var i = 0; i < result.feed.entries.length; i++) { // loop through results
var entry = result.feed.entries[i],
content = entry.content, // get "content" which includes img element
regex = /src="(.*?)"/, // look for img element in content
src = regex.exec(content)[1]; // pull the src out,
// put our link to the pin with img into our container:
container.innerHTML = '<a href="'+ entry.link + '" target="_blank"><img src="'+ src + '" /></a>';
}
}
});
}
google.setOnLoadCallback(initialize);