Advertisement
denyjackrose

Untitled

Jul 19th, 2018
1,655
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.18 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Solwin Infotech
  4.  * Solwin Instagram Extension
  5.  *
  6.  * @category   Solwin
  7.  * @package    Solwin_Instagram
  8.  * @copyright  Copyright © 2006-2016 Solwin (https://www.solwininfotech.com)
  9.  * @license    https://www.solwininfotech.com/magento-extension-license/
  10.  */
  11. $helper = $this->helper('\Solwin\Instagram\Helper\Data');
  12. $enable = $helper->getConfig('instagramsection/instagramgroup/active');
  13. $userId = $helper->getConfig('instagramsection/instagramgroup/userid');
  14. $accessToken = $helper->getConfig('instagramsection/instagramgroup/accesstoken');
  15. $imageNumber = $this->getData('numberimage');
  16. $imageResolution = $this->getData('resolution');
  17. ?>
  18.  
  19. <?php
  20. if ($enable) {
  21.     ?>
  22.     <div class="block-title-main">
  23.         <h2><?php echo $this->getData('title'); ?></h2>
  24.         <div class="title-border"></div>
  25.     </div>
  26.     <div id="cpcolumninstagram" class="cp-fcontent hidden-xs">
  27.         <?php
  28.         $url = 'https://api.instagram.com/v1/users/' . $userId . '/media/recent/?access_token=' . $accessToken.'&count='.$imageNumber;
  29.         $args = stream_context_create(array('http' => array('timeout' => 2500,)));
  30.         //for Live server
  31.         $instagramFeedsData = file_get_contents($url, false, $args);
  32.         // for Local Server
  33.         // $instagramFeedsData = $helper->getInstangramData($url);
  34.  
  35.         $instagramFeeds = json_decode($instagramFeedsData);
  36.  
  37.         $instangramData = $instagramFeeds->data;
  38.         foreach ($instangramData as $instagramFeed) {
  39.             $instagramImage = $instagramFeed->images->$imageResolution->url;
  40.             ?>
  41.  
  42.             <?php
  43.             $caption_text = 'Instagram';
  44.             if (is_object($instagramFeed->caption)) {
  45.                 $caption_text = $instagramFeed->caption->text;
  46.             }
  47.             ?>
  48.             <div class="instangram-feed">
  49.                 <a href ="<?php echo $instagramFeed->link; ?>" target="_blank">
  50.                     <img src="<?php echo $instagramImage; ?>" title="<?php echo $caption_text; ?>" alt="<?php echo $caption_text; ?>"/>
  51.                 </a>              
  52.             </div>
  53.             <?php
  54.         } ?>
  55.     </div>
  56.     <div class="clear gap-30"></div>
  57. <?php }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement