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

Does anyone know if it's possible to get the standard resolution image as square rather than non-square at all?

Share this post


Link to post
Share on other sites

Is there any plans to update this to work with new instagram Graph API, as the plugin stopped working as support for the /users/{id}/media/recent has been deprecated as of the 4th April 2018

Share this post


Link to post
Share on other sites

Cool to have a Module set up for this @justb3a! Cheers! 😄

I've been reading the topic, but still have a question – not so much about the implementation, but more in options I guess;
In understand that it's connected to Sandbox users, but as I'm filling in one user, I take it it's not possible to fill in multiple users?

(either in the module-field, or chained in the getRecentMedia('user1, user2')?
...Just wondering, as I'm working with a collective that has multiple accounts.

Share this post


Link to post
Share on other sites

I see this notice:

[InstagramFeed]: No data was received for 'nome_user' (recentmedia).
[InstagramFeed]: No user 'nome_user.it' was found.

 I use the correct user name and I checked all the keys access and these are correct, also the token. I saw that the account registered the permission to use my app. So, I don't know maybe I miss something... What I can check ?

 

FIXED:

In the end I find that if I disable implicit OAuth and not force the signed requests everything works well. btw I don't know if is a good things!

 

UPDATE:

I still see this error in the log page every time some one visit the page:  [InstagramFeed]: No user 'xxx' was found.

The page work well, but why I see this error and how I can delete it?

Thank you

Share this post


Link to post
Share on other sites

Is there a way to get media with a certain tag limited to one user with this module. Have tried chaining getRecentMediaByTag() but I don't think that's possible.

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 BitPoet
      MediaLibrary
      Update: MediaLibrary can now be found in the official module list.
      Out of necessity, I've started to implement a simple media library module.
      The basic mechanism is that it adds a MediaLibrary template with file and image fields. Pages of this type can be added anywhere in the page tree.
      The link and image pickers in CKEditor are extended to allow quick selection of library pages from dropdowns. In the link picker this happens in the MediaLibrary tab, where you can also see a preview of the selected image. In the image picker, simply select a library from the dropdown at the top, everything else is handled by standard functionality.
      I've put the code onto github. This module is compatible with ProcessWire 3.
      Steps to usage:
      Download the module's zip from github (switch to the pw3 branche beforehand if you want to test on PW 3.x) and unpack it into site/modules Click "Modules" -> "Refresh" in the admin Click "Install" for MediaLibrary For testing, create a page with the MediaLibrary template under home (give it an expressive title like 'Global Media') and add some images and files Edit a differnt page with a CKEditor field and add a link and an image to see the MediaLibrary features in action (see the screencap for details) Optionally, go into the module settings for MediaLibrary Note: this module is far from being as elaborate as Kongondo's Media Manager (and doesn't plan to be). If you need a feature-rich solution for integrated media management, give it a look.
      Feel free to change the settings for MediaFiles and MediaImages fields, just keep the type as multiple.
      There are some not-so-pretty hacks for creating and inserting the correct markup, which could probably be changed to use standard input fields, though I'm a bit at a loss right now how to get it to work. I've also still got to take a look at error handling before I can call it fit for production. All feedback and pointers are appreciated (that's also why I post this in the development section).

      Edit 09.03.2016 / version 0.0.4: there's now also a "Media" admin page with a shortcut to quickly add a new library.

      Edit 01.05.2016:
      Version 0.0.8:
      - The module now supports nested media libraries (all descendants of eligible media libraries are also selectable in link/image picker).
      - There's a MediaLibrary::getPageMediaLibraries method you can hook after to modify the array of available libraries.
      - You can switch between (default) select dropdowns or radio boxes in the module configuration of MediaLIbrary to choose libraries.
      Edit 10.10.2018:
      Version 0.1.3:
      - Dropped compatibility for ProcessWire legacy versions by adding namespaces
      - Allow deletion of libraries from the Media overview admin page
      - Added an option to hide media libraries from the page tree (optionally also for superusers)
    • By Robin S
      This module corrects a few things that I find awkward about the "Add New Template" workflow in the PW admin. I opened a wishlist topic a while back because it would good to resolve some of these things in the core, but this module is a stopgap for now.
      Originally I was going to share these as a few standalone hooks, but decided to bundle them together in a configurable module instead.
      Add Template Enhancements
      A module for ProcessWire CMS/CMF. Adds some efficiency enhancements when adding or cloning templates via admin.

      Features
      Derive label from name when new template added: if you like to give each of your templates a label then this feature can save some time. The label can be added automatically when templates are added in admin, in admin/API, or not at all. There are options for underscore/hyphen replacement and capitalisation of the label. Edit template after add: when adding only a single template, the template is automatically opened for editing after it is added. Copy field contexts when cloning: this copies the field contexts (a.k.a. overrides such as column width, label and description) from the source template to the new template when using the "Duplicate/clone this template?" feature on the Advanced tab. Copy field contexts when duplicating fields: this copies the field contexts if you select the "Duplicate fields used by another template" option when adding a new template. Usage
      Install the Add Template Enhancements module.
      Configure the module settings according to what suits you.
       
      https://github.com/Toutouwai/AddTemplateEnhancements
      https://modules.processwire.com/modules/add-template-enhancements/
    • By Mike Rockett
      As I mentioned in this issue, I've create a new textformatter for ParsedownExtraPlugin, which adds some oomph to your markdown.
      Repo: Parsedown Extra Plugin
      Unlike the built-in textformatter for Parsedown and Parsedown Extra, this should be used when you want to use Extra with additional configuration/customisation.
      Some examples:
      ### Test {.heading} - A [external link](https://google.com/){.google} with `google` as a class that opens in a new tab if the config property is set. - [Another link](/page){target=_blank} that opens in a new tab even though it isn't external. ```html .html <p>Test</p> ``` There's some config options available to you, such as setting attributes on all/external images and links, setting table and table-cell alignment classes, adjusting footnote classes and IDs, adding <code> attributes to their parent <pre> elements, and changing the <code> class if your syntax highlighter does not use language-*.
      I was thinking about adding the ability to make links open in a new tab by appending a plus to the link syntax, but only external links should be opening in a new tab anyway. Further, this would add extra, unnecessary processing time.
      Please let me know if you bump into any problems. ☺️
    • By Mike Rockett
      TextformatterTypographer (0.4.0 Beta)
      A ProcessWire wrapper for the awesome PHP Typography class, originally authored by KINGdesk LLC and enhanced by Peter Putzer in wp-Typography. Like Smartypants, it supercharges text fields with enhanced typography and typesetting, such as smart quotations, hyphenation in 59 languages, ellipses, copyright-, trade-, and service-marks, math symbols, and more.
      Learn more on my blog
      It's based on the PHP-Typography library found over at wp-Typography, which is more frequently updated and feature rich that its original by KINGdesk LLC.
      The module itself is fully configurable. I haven't done extensive testing, but there is nothing complex about this, and so I only envisage a typographical bug here and there, if any.
      Please do test it out and let me know what you think.
      Also note that I have indicated support for PW 2.8, but I haven't tested there as yet. This was built on PW 3.0.42/62.
    • By Mike Rockett
      Jumplinks for ProcessWire
      Release: 1.5.50
      Jumplinks is an enhanced version of the original ProcessRedirects by Antti Peisa.
      The Process module manages your permanent and temporary redirects (we'll call these "jumplinks" from now on, unless in reference to redirects from another module), useful for when you're migrating over to ProcessWire from another system/platform. Each jumplink supports wildcards, shortening the time needed to create them.
      Unlike similar modules for other platforms, wildcards in Jumplinks are much easier to work with, as Regular Expressions are not fully exposed. Instead, parameters wrapped in curly braces are used - these are described in the documentation.
      Under Development: 2.0, to be powered by FastRoute
      As of version 1.5.0, Jumplinks requires at least ProcessWire 2.6.1 to run.
      View on GitLab
      Download via the Modules Directory
      Read the docs
      Features
      The most prominent features include:
      Basic jumplinks (from one fixed route to another) Parameter-based wildcards with "Smart" equivalents Mapping Collections (for converting ID-based routes to their named-equivalents without the need to create multiple jumplinks) Destination Selectors (for finding and redirecting to pages containing legacy location information) Timed Activation (activate and/or deactivate jumplinks at specific times) 404-Monitor (for creating jumplinks based on 404 hits) Additionally, the following features may come in handy:
      Stale jumplink management Legacy domain support for slow migrations An importer (from CSV or ProcessRedirects) Feedback & Feature Requests
      I’d love to know what you think of this module. Please provide some feedback on the module as a whole, or even regarding smaller things that make it whole. Also, please feel free to submit feature requests and their use-cases.
      Note: Features requested so far have been added to the to-do list, and will be added to 2.0, and not the current dev/master branches.
      Open Source

      Jumplinks is an open-source project, and is free to use. In fact, Jumplinks will always be open-source, and will always remain free to use. Forever. If you would like to support the development of Jumplinks, please consider making a small donation via PayPal.
      Enjoy!