コード例 #1
0
<?php

/**
 * Created for php-instagram-feed
 * User: Danny Hearnah
 * Author: Skyblue Creations Ltd.
 *
 * Date: 15/07/2015
 * Time: 08:24
 */
require 'class/InstagramFeed.php';
$username = '******';
$instagram = new InstagramFeed($username);
// print a selection of images
$offset = 0;
$limit = 10;
$media = $instagram->getMedia($offset, $limit);
if ($media) {
    ?>
	<ul>
		<?php 
    foreach ($media as $m) {
        ?>
			<li>
				<img src="<?php 
        echo $m['display_src'];
        ?>
"><br>
				<?php 
        echo $m['caption'];
        ?>
コード例 #2
0
 public function start_aggregation()
 {
     $this->log('<<<<<<<<<<<<<<<<<<<<<<<<<< start aggregation..');
     // increasing maximum execution time to 3 min for this part, it can take more time
     // than the default 30 secs for the images to be downloaded and processed by PHP/WP..
     // set_time_limit(180);
     $feed_enabled = false;
     // fetch from Facebook..
     $options = get_option('facebook_page');
     if (isset($options[$this->prefix . 'enabled'])) {
         $feed_enabled = true;
         $fb = new FacebookFeed();
         $result = $fb->getFeed($options);
         if ($this->feed_error($result)) {
             return $result['message'];
         } else {
             $this->save_feed_items($result, $this->sections[$this->prefix . 'facebook']);
         }
     }
     // fetch from Twitter..
     $options = get_option('twitter_page');
     if (isset($options[$this->prefix . 'enabled'])) {
         $feed_enabled = true;
         $tw = new TwitterFeed();
         $result = $tw->getFeed($options);
         if ($this->feed_error($result)) {
             return $result['message'];
         } else {
             $this->save_feed_items($result, $this->sections[$this->prefix . 'twitter']);
         }
     }
     // fetch from Instagram..
     $options = get_option('instagram_page');
     if (isset($options[$this->prefix . 'enabled'])) {
         $feed_enabled = true;
         $in = new InstagramFeed();
         $result = $in->getFeed($options);
         if ($this->feed_error($result)) {
             return $result['message'];
         } else {
             $this->save_feed_items($result, $this->sections[$this->prefix . 'instagram']);
         }
     }
     // fetch from YouTube..
     $options = get_option('youtube_page');
     if (isset($options[$this->prefix . 'enabled'])) {
         $feed_enabled = true;
         $yt = new YouTubeFeed();
         $result = $yt->getFeed($options);
         if ($this->feed_error($result)) {
             return $result['message'];
         } else {
             $this->save_feed_items($result, $this->sections[$this->prefix . 'youtube']);
         }
     }
     // fetch from Vimeo..
     $options = get_option('vimeo_page');
     if (isset($options[$this->prefix . 'enabled'])) {
         $feed_enabled = true;
         $vim = new VimeoFeed();
         $result = $vim->getFeed($options);
         if ($this->feed_error($result)) {
             return $result['message'];
         } else {
             $this->save_feed_items($result, $this->sections[$this->prefix . 'vimeo']);
         }
     }
     // fetch from RSS Feed..
     $options = get_option('rss_page');
     if (isset($options[$this->prefix . 'enabled'])) {
         $feed_enabled = true;
         $rss = new RssFeed();
         $result = $rss->getFeed($options);
         if ($this->feed_error($result)) {
             return $result['message'];
         } else {
             $this->save_feed_items($result, $this->sections[$this->prefix . 'rss']);
         }
     }
     $this->log('>>>>>>>>>>>>>>>>>>>>>>>>>> aggregation complete..!');
     if (!$feed_enabled) {
         return 'No social feeds are enabled. <a href="edit.php?post_type=' . $this->post_type . '&page=' . $this->settings_slug . '">Enable some feeds.</a>';
     }
 }