Skip to content

Instantly share code, notes, and snippets.

@rhcarlosweb
Last active August 30, 2017 23:07
Show Gist options
  • Save rhcarlosweb/e2ef3fbd1561806fb5ef91f142a37319 to your computer and use it in GitHub Desktop.
Save rhcarlosweb/e2ef3fbd1561806fb5ef91f142a37319 to your computer and use it in GitHub Desktop.
Pinterest Last Pin Feed with PHP

Show last pins base on your pinterest feed

Simple function php

<?php
function nexo_pinterest_feed( $username = null, $countImg = 20 ) {
$pin_feed_url = "https://br.pinterest.com/" . $username . "/feed.rss/";
$result_pin = file_get_contents( $pin_feed_url );
$result_pin = simplexml_load_string( $result_pin );
$pin_count = 1;
foreach ( $result_pin->channel->item as $item ) {
// link
$item_link = $item->link;
// description
$item_description = $item->description;
$regex = "/<img((?:[^<>])*)>/";
preg_match( $regex, $item_description, $matches );
echo '<a href="' . $item_link . '" target="_blank">' . $matches[0] . '</a>';
if ( $pin_count == $countImg ) {
break;
}
$pin_count ++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment