Skip to content

Instantly share code, notes, and snippets.

@zoerooney
Last active December 22, 2015 10:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zoerooney/2299f1623ed03e5ffd69 to your computer and use it in GitHub Desktop.
Save zoerooney/2299f1623ed03e5ffd69 to your computer and use it in GitHub Desktop.
Pinterest via RSS feed and Google Feed API, as discussed here: http://zoerooney.com/blog/tutorials/display-a-pinterest-feed-almost-anywhere-via-rss/
<div id="pinfeed"></div>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<!-- ref: https://developers.google.com/feed/v1/devguide -->
<script type="text/javascript">
google.load('feeds', '1');
function initialize() {
var feed = new google.feeds.Feed('https://www.pinterest.com/username/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);
</script>
@qlt
Copy link

qlt commented Sep 28, 2015

Hi Zoe,

When i change the setNumEntries value to let's say 4 it loads the fourth image and not 4 images. Is there something else I need to change to get a result which displays more than one image?

@julien51
Copy link

Hum. The Google Feed API has been deprecated. You can use Superfeedr as an alternative feed API!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment