-
Posts
319 -
Joined
-
Last visited
-
Days Won
9
Everything posted by nbcommunication
-
Hi @jonatan, No, I think echoing as you are doing would probably be faster if anything. Basically no difference - I just like to use the array so I don't have to wrap with <div></div> in three separate places. I'm going to look into making the pagination more available through the module tomorrow. Might be tricky, and it probably will need to be batches of 24, but I definitely think you've made a good case that it should be available. I think that may have been from the previous API. This one returns the first 24 items, and a link for getting the next 24. You can keep going on until all items have been received or until the API limits have been maxed out. Indeed, this is what would happen if you were to call something like InstagramBasicDisplayApi::getMedia(10000), although I think there would be a timeout before completion. If you request 89 and there are only 80, it should return 80, but I don't think I actually tested that. I don't have access to an account at the moment with a relatively small amount of items, but should do soon, so will test this when I can. I suspect there is an issue and this is why you are getting the undefined offset errors and the blank items. For debugging, I'd add the following to your code: <?php $images = $instagram->getMedia(89); echo count($images) . "<br>" . print_r($images, 1); If you are requesting 80 items, and 10 of those are album carousels, that should be 14 calls to the API (24, 24, 24, 24[8] + a call for each carousel). How many carousels do you have? When I was developing and testing I didn't budge the limit off 0%. Will have another look at this tomorrow. I think it may be useful to have an option to not get the full carousel when using getMedia() as this does seem to be the issue. I'm not following this. I think I know what you mean now I've gone through the following... I'll tweak your code to what I think you are trying to achieve and that'll maybe get us closer: <?php $username = "a_username"; $account = $instagram->getProfile($username); $postsnum = $account["media_count"] ?? 0; // If the API request is unsuccessful, the post count below will not be displayed ?> <div class="col-12 text-center mb-3"> <a href="https://instagram.com/<?= $username ?>/" target="_blank" class="marked"> <h3 class="marked my-5 instalink">@<?= $username ?></h3> </a> <?php if($postsnum): ?><h5 class="marked-dark"><?= $postsnum ?> POSTS / OPSLAG </h5><?php endif; ?> </div> getProfile() is a single call which will be cached for either an hour or however long you have the cache time set to so I wouldn't consider this a resource issue. Given that the cache time will be the same for getMedia(), the count and the number of items you get if you were to get them all should be the same, but the count won't update until the cache has expired. getUserAccount() should have the same value for media_count, but it is only updated when getProfile() is called (and an API request is made) so I don't think it is worth using in this situation. It is a public method but only so it could be used in the config - I can't think of a situation where it should be used over getProfile(). The errors you've pointed out in your last post are related to the total number issue which I'll get fixed as soon as I can. I'll hopefully have some progress on this tomorrow! Thanks again for your feedback! Cheers, Chris
-
Hi @jonatan, I'll have a think about how best to implement a lazy-load. I'll need to provide a way to return the "next" link to do this. The cache time is set in the module configuration, should be 3600 by default. Quite possible that the single request is maxing out the limit, will look at that later. Cheers, Chris
-
Hi @jonatan, I'll provide a fuller response later but just a couple of things now: The API doesn't actually allow for querying a specific number of items like the old one did. The module actually uses the built in pagination to retrieve as many items as requested in the call. That's why it is taking a while. You should have a cache time of at least 3600 seconds (an hour) if you are requesting this many items. This will prevent maxing out the limits (which is a lot easier to do when developing anyway!). If I were in your position, I'd be weighing whether so many items need to be displayed. I'd probably just display the first batch (e.g. $images = $instagram->getMedia()) which returns 24 items normally. For the PHP error: <?php foreach($images = $instagram->getMedia(89) as $post) { ... } // I'd change this to: $images = $instagram->getMedia(89); if(count($images)) { foreach($images as $post) { ... } } Cheers, Chris
-
Hi @gowthamg, The instructions for this module, for setting up the facebook app are here: https://github.com/nbcommunication/InstagramBasicDisplayApi/blob/master/README.md and relate exclusively to this part of the facebook/instagram docs: https://developers.facebook.com/docs/instagram-basic-display-api/overview#user-token-generator. I'd advise reviewing the errors displayed on your screenshot - notes and screencast are missing. If you do have success in getting the app reviewed and approved, please share here, but as I said previously, this isn't in the purview of this module. Cheers, Chris
-
Hi @gowthamg - I can't help you here I'm afraid. This module and the instructions provided are not geared toward app review. Cheers, Chris
-
Hi @gowthamg, What do you mean by all users? In the past, getting Instagram data from any user was pretty simple, but it is locked down now. You can only retrieve data from users who have authorised your app. This module is built around the oAuth token generator provided by facebook, which allows you to add a "test" Instagram user, and then generate a token by logging in as that user and authorising the app. This bypasses the need to submit the app for review, which is intended for apps that would be public facing. You can only get data from users that have authorised your app, and in this case of this module, you need to login as the user to authorise it. For a number of clients recently we've arranged a time where they change their password to something temporary and let us know the temp password, we run through the steps in the README and get the app/module set up, and then let the client know so they can change their password back. It has worked well so far. Cheers, Chris
-
Hi @jonatan, Many thanks for your feedback, and for helping out @gowthamg. You are correct - looks like he's trying to set up the full API which isn't what this module uses. I've updated the README with the module call in each example, and also added an example for getMedia() which demonstrates how to build a multi-media gallery using UIkit. I've attached a video example of the result ? Here's the code I added to the README: // Function for rendering items function renderInstagramItem($src, $alt, $href = null) { if(is_null($href)) $href = $src; return "<a href='$href' data-caption='$alt' " . ($src !== $href ? "data-poster='$src' " : "") . "class='uk-display-block uk-cover-container'>" . "<canvas width='640' height='640'></canvas>" . "<img src='$src' alt='$alt' data-uk-cover>" . "</a>"; } // Get the module $instagram = $modules->get("InstagramBasicDisplayApi"); // Get the 16 most recent items and render them based on type $items = []; foreach($instagram->getMedia(16) as $item) { switch($item->type) { case "VIDEO": $items[] = renderInstagramItem($item->poster, $item->alt, $item->src); break; case "CAROUSEL_ALBUM": // If 4 or greater items, display a grid of the first 4 images // Otherwise display the main image (no break, moves to default) if($item->children->count() >= 4) { $items[] = "<div class='uk-grid-collapse uk-child-width-1-2' data-uk-grid>" . $item->children->find("limit=4")->each(function($item) { return "<div>" . renderInstagramItem($item->src, $item->alt) . "</div>"; }) . "</div>"; break; } default: // IMAGE $items[] = renderInstagramItem($item->src, $item->alt); break; } } // Render the items as a grid echo "<div class='uk-grid-collapse uk-child-width-1-2 uk-child-width-1-4@s' data-uk-grid data-uk-lightbox>"; foreach($items as $item) { echo "<div>$item</div>"; } echo "</div>"; The query about data-width - this is a totally separate thing unfortunately. That's the oEmbed implementation from which you get a HTML embed code which normally includes javascript from the provider, and in the case of Instagram includes code which handles a data-width attribute. There's nothing like that here. This API gives you basic data, and it is up to you to render it. I'd actually recommend looking more into oEmbed if you are looking to embed single posts in articles or similar. The main purpose of this module and the API itself is a standalone "feed" or gallery of user media. Cheers, Chris instagram-basic-display-api-2020-03-21.mp4
-
Hey, If anyone has installed and implemented this module, please let me know if you've any feedback! I've currently only used it as a replacement for InstagramFeed, and it has worked great ? Cheers, Chris
-
Hi @Ben Sayers, The `src` returned is a direct link to the image on Instagram's CDN - there are no API options for resizing. When I've used a lightbox I just use `src` for both the "img src" and "a href" attributes. Cheers, Chris
-
Hi Ben, Glad to hear you got the account authorised ? Pop this before your call: $instagram = $modules->get("InstagramBasicDisplayApi"); Cheers, Chris
-
Hello, With the API being deprecated at the end of this month, I've built a replacement module which uses the Instagram Basic Display API. Find out more here: Cheers, Chris
-
Hi, The module is now ready for use in production. It is still in Beta as I need to test token renewal, but cannot do this yet due to how token renewal works. Cheers, Chris
-
Hi @lpa, Apologies for the late response. I've had a look at this... Number 2 - width and height attributes not rendering - this isn't anything to do with PageimageSrcset. These options, when passed to Pageimage::render(), resize the image, but don't get rendered as attributes. If you want this behaviour, adding a markup option should do the trick: $content .= $img->render([ 'alt'=> $img->name, 'height' => $img->height, 'width' => $img->width, 'srcset' => '883, 687, 369', 'markup' => "<img src='{url}' alt='{alt}' width='{width}' height='{height}' />" ]); As for portrait mode, I'm not getting this when I test. I get: <img src='/site/assets/files/1033/placeholder-city.691x499.1000x667.webp' alt='placeholder-city.jpg' srcset=' /site/assets/files/1033/placeholder-city.369x266-srcset.webp 369w, /site/assets/files/1033/placeholder-city.687x496-srcset.webp 687w, /site/assets/files/1033/placeholder-city.691x499.webp 883w' > In your example, the image isn't being resized as portrait, so it is odd that the sizes attribute is being added. What settings do you have in the module config for Portrait mode? Are you on the latest version of the module (1.01)? Cheers, Chris
-
Thanks @LAPS, have added that to my master copy and will add it to the repo soon.
-
Hi @LAPS, Have a look at new() in WireMailTools. This is where the WireMail module is set either explicitly through a passed option or config setting, or inferred. Going by your first post, I think you may be able to set $config->wireMail, so it just uses default WireMail. Cheers, Chris
-
@LAPS, @adrian - I only use WireMailgun and don't use ProMailer, so I'm not the best person to check with... However, as I understand it, any WireMail module installed supersedes the core WireMail functionality. For example, system error / forgot password emails we receive are sent through Mailgun. I've no idea how multiple WireMail modules are handled, but I assume that ProMailer gives you the option to choose which to use? Cheers, Chris
-
Hi, this module is now in Beta. Still to add full documentation and Facebook App tips. Aiming to complete by the end of the week!
-
Hi, I've updated this module with a lot of progress - still should be considered alpha, but should be ready for production soon. Cheers, Chris
-
Hi @montero4, That all makes sense. You can also do the following: // Create an image variation 1200px wide with -srcset suffix $image = $page->image->width(1200, ["suffix" => "srcset"]); echo "<img src='$image->url' alt='$alt_text' srcset='$image->srcset'>"; // PageimageSrcset will use the original to generate the srcset value If you have a look at the Pageimage options, you can add a suffix to the filename when resizing. Cheers, Chris
-
Hi @montero4, I'm sorry, I'm still not following? There's nothing stopping you changing the src - you should resize the image first: // Get the image $image = $page->images->first; // Resize the image $image = $image->size(1024, 468); // Output the image echo "<img src='$image->url' alt='$image->description' srcset='$image->srcset'>"; // Or alternatively echo $image->render(); PageimageSrcset recognises that it is an image variation and then uses the original to generate srcset variations. It isn't really this module's job to handle the src attribute. In theory you could do some manipulations of the "srcset" value to extract the first or last image for use, but I'd say it is a lot cleaner just to resize the image. Cheers, Chris
-
For folk using the module - is the configuration of sets in the textarea working OK for you? I've been mulling over trying to build something a bit more user-friendly, like a kind of repeater field for entering data, but I'm not convinced that it would actually be easier to work with, particularly as I usually only enter an image width per line and that's it. In a future version I want to add the configuration on a per-field basis (maybe even per-image even though that would be overkill), so I want to get the configuration method as solid as possible first. Perhaps retaining the textarea, but with a live preview would be the best option? I'm also not sure whether it is useful to have portrait mode and UIkit widths as config options. Ultimately the module is meant to extend Pageimage so that srcset and sizes can be used - I feel these config options are a result of my own bias in how I use the module, and yet I don't think I've used the portrait option at all! Any ideas/thoughts you have, please come with them! Cheers, Chris
-
Hi @adrian, Finally gotten a look - it was as I expected. When an email address is passed to WireMail::to() it is run through WireMail::sanitizeEmail(). This passes the email through both strtolower() and trim(). addRecipientVariables() was just using Sanitizer::email(), which doesn't pass the email through strtolower/trim, resulting in different keys. I've changed it to use sanitizeEmail(). Sorry it's taken so long to fix! Cheers, Chris
-
Hi, With the deprecation of Instagram's API and therefore the end of the Instagram Feed module, I've developed a replacement module which uses the Instagram Basic Display API: https://github.com/nbcommunication/InstagramBasicDisplayApi To use this module you'll need: ProcessWire >= 2.7 A Facebook Developer account Access to the Instagram user account you wish to use Prior to installation, you'll need to create a Facebook app. The app you will create uses the User Token Generator for authentication - it does not need to be submitted for App Review (and therefore stays in Development mode). The README contains full instructions on how to create and set up the app and also how to use the module. The primary reason for this module's development was to retain functionality on existing websites that use the Instagram Feed module. To assist with upgrading, this module replicates some methods provided by Instagram Feed. I've already upgraded a couple of sites and it was quick and painless ? Cheers, Chris
-
@teppo, having read a bit about <picture>, it probably would make sense to provide this functionality in the module, but possibly as a separate method distinct from render(). I’ve got a fair bit I want to do on this module, but it’s behind a lot of other work at the moment. I’ll add this to the todo list, but for the time being, I would go with writing something for your own use. Cheers, Chris
-
Hi @montero4, Can you please give a code example? From your description, it seems to me that all you need to do is resize the pageimage before rendering/getting attributes. Cheers, Chris