Jump to content

Module: Instagram Feed


justb3a

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?

Link to comment
Share on other sites

  • 2 weeks later...

@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.

Link to comment
Share on other sites

  • 3 months later...

@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
Link to comment
Share on other sites

  • 2 weeks later...

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

Link to comment
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?

Link to comment
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.

Link to comment
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

 

Link to comment
Share on other sites

  • 8 months later...

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?

Link to comment
Share on other sites

  • 2 months later...

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...

Link to comment
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>

 

 

 

Link to comment
Share on other sites

  • 2 months later...
  • 1 month later...
  • 1 month later...

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.

Link to comment
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

Link to comment
Share on other sites

  • 2 weeks later...

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
×
×
  • Create New...