justb3a

Module: Instagram Feed

Recommended Posts

Ahhhh, you know what it could be! I am currently using hosts file to point a domain to another IP address so the rediercts url will be hitting a different server!

Do you think that is it?

Is there any work around whilst I'm in development to get this working on the server I am on?

Share this post


Link to post
Share on other sites

I keep getting the following error - [InstagramFeed]: No user '' was found. However it's working fine. 

Share this post


Link to post
Share on other sites

@justb3a Is it only possible to retrieve the recentMedia of the sandbox user?
EDIT: To clarify: Can I just access images of the access token user or can I get images from every user?

I get the images of my own account (which is in sandbox mode) but if I enter something diffent in the field "Username" in the modules settings, I still get the same images and not the images of the other user.

I even tried

$instagram = $modules->get('InstagramFeed')->getRecentMedia("cocacola");

but still my own images appear. I also tried clearing the cache via the link in the modules setting.

Share this post


Link to post
Share on other sites

The sandbox api is limited to sandbox users everywhere, so even retrieving by tag does only show images of those. You cannot get any other users media.

  • Like 1

Share this post


Link to post
Share on other sites

Hi everyone,

This is a great module. I was just wondering if anyone knows whether it would be possible for me to pull the location of each Instagram post and if so what the correct call is?

Thanks,

Matt

Share this post


Link to post
Share on other sites

@Matt_P If you use the `getRecentMedia()` endpoint you should be able to access the location inside the foreach loop.  Have a look at the instagram api, expand the response and there you'll see an example response containing all data which will be returned including a location entry.

"location": {
  "latitude": 37.778720183610183,
  "longitude": -122.3962783813477,
  "id": "520640",
  "street_address": "",
  "name": "Le Truc"
}

Code example (not tested):

<?php $feed = $modules->get('InstagramFeed')->getRecentMedia(); ?>

<div class="instagram">
  <?php foreach ($feed as $media): ?>
    // check if location is not `null`
    <?php if ($location = $media['location']): ?>
      Location: <?= $location['name'] ?>
    <?php endif; ?>
  <?php endforeach; ?>
</div>

 

  • Like 1

Share this post


Link to post
Share on other sites

Hi everyone,

Do you think it would be possible to save the last 20 or so medias (due to instagram sandbox mode), as if they would have been uploaded on the site?

In order for them not to disappear when the new posts arrive.

Mainly, the idea would be to have the complete feed displayed.

 

I did it manually with the medias urls for now but they keep changing so it's not a very suitable solution…

 

Thanks

Share this post


Link to post
Share on other sites

hi @Tanky you could add an image field to your page and save the image there.

Try something like the following:

$page->of(false);
$page->images->add($media['images']['standard_resolution']['url']);
$page->save("images");

 

Share this post


Link to post
Share on other sites

I pasted your code in the foreach that I use to generate each media of the feed:

$page->setOutputFormatting(false);
$page->insta_image->add($media['images']['standard_resolution']['url']);
$page->save("insta_image");

It returns me this error, which is weird because you already disabled the output formatting:

Error: Exception: Can't save field from page 1: /: Call $page->setOutputFormatting(false) before getting/setting values that will be modified and saved. [insta_image] (in /home/tenutaxyit/www/wire/core/PagesEditor.php line 783)

 

And there is something else I thought about, each time someone will load the page the images will be saved again, so how could I check if a media is already backed up before saving it?

Share this post


Link to post
Share on other sites

@Tanky Sorry, I have not the time at the moment to try this myself. But this is more a general topic, please try to use the forum search, I know there are a lot of topics which cover how to add an image via api. If you want to have an "archive"/Feed of all images/posts, you should consider to decouple the process of saving images from displaying it on the webpage. I would set up a cronjob or something like this which "asks" repeatedly at certain time intervals whether there are new posts. Then you could add a new Page / Page-Table-Item / Repeater-Item (it's up to you how to save it) containing the image and all the desired data (location, comments, ..) as well as the id (`$media['id'|`). Simply check if you already have an item with that id. You could also check whether `$media['created_time']` is greater than the last inserted item.

Or even better: the endpoint supports additional parameters which could be implemented as well:

MAX_ID    Return media earlier than this max_id.
MIN_ID    Return media later than this min_id.

Using MIN_ID you should be able to only receive new posts/images.

Share this post


Link to post
Share on other sites
On 18/10/2016 at 2:42 PM, Tom. said:

I keep getting the following error - [InstagramFeed]: No user '' was found. However it's working fine. 

Hi @Tom., did you solve this? It is working fine, but the the error keeps popping up.

58a88e8c5e2a8_ScreenShot2017-02-18at19_12_15.png.e7044782bfa606426a508b460d425bd8.png

I commented out line #317 of InstagramFeed.module to stop the logging for now.

58a88e54baaf3_ScreenShot2017-02-18at19_10_00.png.84587a9e5a584c006ff6608c63c6aaa8.png

 

Share this post


Link to post
Share on other sites

Here's a question. is there a way of setting the imageCount value when initialising the module. I don't think there is taking a look at the modules methods but perhaps I'm wrong?

This might be handy in the instance where you want to have one page show say 4 images and another show 8.

I know you could do this when iterating and limit but might be able to set limit based on each instance of the instagram feed?

Share this post


Link to post
Share on other sites

There you go:

<?php $feed = $modules->get('InstagramFeed')->setImageCount(8)->getRecentMedia();  ?>

 

  • Like 2

Share this post


Link to post
Share on other sites

Has any one noticed a problem with Instagram posts with multiple images not showing?

I get the output:

// output video  

suggesting that "multiple image" posts are not picked up as media type "image".

<?php if ($media['type'] === 'image'): ?>

With thanks...

Share this post


Link to post
Share on other sites

Found a fix for posts with multiple images...

Replace

// output video

with:

      <a href="<?=$media['link']; ?>" class="instagram-item">
        <picture>
          <source media="(min-width: 55rem)" srcset="<?=$media['images']['standard_resolution']['url']; ?>">
          <source media="(min-width: 45rem)" srcset="<?=$media['images']['low_resolution']['url']; ?>">
          <source srcset="<?=$media['images']['thumbnail']['url']; ?>">
          <img src="<?=$media['images']['thumbnail']['url']; ?>" alt="">
        </picture>
      </a>

e.g.

<div class="instagram">
  <?php foreach ($feed as $media): ?>
    <?php if ($media['type'] === 'image'): ?>
      <a href="<?=$media['link']; ?>" class="instagram-item">
        <picture>
          <source media="(min-width: 55rem)" srcset="<?=$media['images']['standard_resolution']['url']; ?>">
          <source media="(min-width: 45rem)" srcset="<?=$media['images']['low_resolution']['url']; ?>">
          <source srcset="<?=$media['images']['thumbnail']['url']; ?>">
          <img src="<?=$media['images']['thumbnail']['url']; ?>" alt="">
        </picture>
      </a>
    <?php else: ?>
      <a href="<?=$media['link']; ?>" class="instagram-item">
        <picture>
          <source media="(min-width: 55rem)" srcset="<?=$media['images']['standard_resolution']['url']; ?>">
          <source media="(min-width: 45rem)" srcset="<?=$media['images']['low_resolution']['url']; ?>">
          <source srcset="<?=$media['images']['thumbnail']['url']; ?>">
          <img src="<?=$media['images']['thumbnail']['url']; ?>" alt="">
        </picture>
      </a>
    <?php endif; ?>
  <?php endforeach; ?>
</div>

 

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Lex Sanchez
      Video or Social Post Embed
      Based on the TextformatterVideoEmbed module developed by Ryan Cramer, we have added the possibility to embed publications of the main social networks Facebook, Twitter and Instagram.
      ProcessWire Textformatter module that enables translation of YouTube, Vimeo, Instagram, Facebook, Twitter or Issuu URLs to full embed codes, resulting in a viewable video or social post in textarea fields you apply it to.
      How to install
      Download or Clone from Github: https://github.com/lexsanchez/VideoOrSocialPostEmbed
      Copy the VideoOrSocialPostEmbed.module file to your /site/modules/ directory (or place it in /site/modules/VideoOrSocialPostEmbed/).
      Click check for new modules in ProcessWire Admin Modules screen. Click install for the module labeled: "Video or Social Post Embed".
      Now you will be on the module config screen. Please make note of the config options and set as you see fit.
      How to use
      Edit your body field in Setup > Fields (or whatever field(s) you will be placing videos in). On the details tab, find the Text Formatters field and select "Video or Social Post Embed". Save.
      Edit a page using the field you edited and paste in YouTube, Vimeo, Facebook, Twitter, Instagram and/or Issuu URLs each on their own paragraph.
      Example
      How it might look in your editor (like TinyMCE):
      How it works
      This module uses YouTube, Vimeo, Instagram, Facebook, Twitter and Issuu oEmbed services to generate the embed codes populated in your content. After these services are queried the first time, the embed code is cached so that it doesn't need to be pulled again.
      Configuration
      You may want to update the max width and max height settings on the module's configuration screen. You should make these consistent with what is supported by your site design.
      If you change these max width / max height settings you may also want to check the box to clear cache, so that YouTube/Vimeo/Facebook/Twitter/Instagram/Issuu oembed services will generate new embed codes for you.
      Using with Markdown, Textile or other LML
      This text formatter is looking for a YouTube, Vimeo, Instagram, Facebook, Twitter or Issuu video URL surrounded by paragraph tags. As a result, if you are using Markdown or Textile (or something else like it) you want that text formatter to run before this one. That ensures that the expected paragraph tags will be present when VideoOrSocialPostEmbed runs. You can control the order that text formatters are run in by drag/drop sorting in the field editor.
      Copyright 2018 by Ryan Cramer / Updated by Lex Sanchez
    • By kixe
      Email Verification
      This module provides functions to validate email adresses and hosts. The module generates a textfile for blacklisted mailhosts (trashmail), which will be always up to date.
      Download
      https://modules.processwire.com/modules/email-verification/
      API
      // get module $mailcheck = $modules->get('EmailVerification'); // return bool/ string - automatted update of blacklist file $mailcheck->blacklisted(email|domain) // return bool - validate a top level domain, checks against IANA list $mailcheck->validTLD(tld) // return array of punycoded TLDs - cyclic updated, data pulled from IANA $mailcheck->getTLDs(cycle=2592000) // return bool - checks syntax converts to punycode $mailcheck->validDomainName(domain); // return bool - checks punycode encoded syntax $mailcheck->validHostName(host); // return bool - checks syntax and accessibility $mailcheck->validHost(email|domain) // add a single value to blacklist $mailcheck->addToBlacklist(email|domain) USAGE
      $mailcheck = $modules->get('EmailCheck'); $email = 'susi@trashmail.com'; if($mailcheck->blacklisted($email)) echo 'Email Provider not allowed'; if(!$mailcheck->validHost($email)) echo 'Mailhost not available'; Example blacklist file:  blacklist.txt
       
    • By teppo
      Code Blocks Textformatter is a tiny Textformatter module I cooked up to add support for code blocks to text/textarea/RTE fields on some of the sites I work with. Unlike a full-blown Markdown Textformatter – which is something that we already have in the core – this module simply adds support for fenced and inline code blocks.
      The syntax is based on the GitHub code block documentation, so please refer to that for additional instructions. The README at GitHub also includes some basic examples. As with any Textformatter, in order to enable this one, install it and enable it via field settings. Note that there's no syntax highlighting built in (at least for the time being), so use a tool of your choice for that – personally I prefer Prism.js.
      Since this module doesn't use a Markdown tool behind the scenes, but rather some home baked regular expressions, there's always the possibility that I've missed something – but please let me know if you use this module and run into any issues. On the other hand this module should be relatively fast and unobtrusive, as there are no unnecessary bits of code to run 
      GitHub repository: https://github.com/teppokoivula/TextformatterCodeBlocks Modules directory: http://modules.processwire.com/modules/textformatter-code-blocks/
    • By theo
      Here is my first processwire module (beta).
      https://github.com/theo222/ImagePickerField
      A lot of "first times". First time Github, Markdown and of course PW Modules.
      So be gentle please.
      I hope it works.