-
Posts
311 -
Joined
-
Last visited
-
Days Won
8
Everything posted by nbcommunication
-
This module allows you to add Cloudflare's Turnstile CAPTCHA to your website, providing a user-friendly alternative to Google's reCAPTCHA. It is based on MarkupGoogleRecaptcha, allowing for easy switching between the two CAPTCHA systems. If MarkupGoogleRecaptcha is installed, some of its settings are used to configure Turnstile. https://github.com/nbcommunication/MarkupCloudflareTurnstile We've used reCAPTCHA for many years now but have found that it isn't as effective as it should be in reducing spam. It is also pretty annoying. We've recently switched a couple of our 'bigger' sites to use Turnstile (using this module) as the sites were on Cloudflare already. It is definitely a much friendlier captcha for users, still to determine whether it is better at preventing spam, but I expect it will be. Cheers, Chris
-
It's done, just waiting on module approval. More info here: and here: https://github.com/nbcommunication/InstagramMediaDisplay Cheers, Chris
-
Meta are disabling the Instagram Basic Display API on December 4th, 2024. After this point, the InstagramBasicDisplayApi module will no longer function. Meta do provide an API that can be used to access Instagram media, Instagram API with Instagram Login. Using this API I've been able to refactor InstagramBasicDisplayApi as a new module called InstagramMediaDisplay: https://github.com/nbcommunication/InstagramMediaDisplay The main caveat with using this module (and API) is that personal and/or private accounts cannot be used. If you try to generate an access token for a personal account, IG will prompt you to upgrade to a business account. As far as I'm aware this is still a free account, and the main limitation is that you cannot use licensed music in the same way you can on a personal account. I have access to various IG accounts, some personal, some business, and I've never noticed a difference. This new module is built to supersede InstagramBasicDisplayApi and its implementation is practically identical. Upgrading should simply be a case of installing, configuring your new Meta app, authorising the same account(s), and updating the call to the previous module to call this one: <?php // $instagram = $modules->get('InstagramBasicDisplayApi'); $instagram = $modules->get('InstagramMediaDisplay'); Cheers, Chris
-
Hello, I've had a look at Instagram API with Instagram Login and initial results are pretty promising. I actually found it easier to set up the app and generate an access token, and the actual API is easier to work with too. It'll take a bit of work to create a new module for this API, but I should have something ready in plenty of time. Will update here once I have something. Cheers, Chris
-
Hi @DV-JF, So the limitation is that it isn't for use by personal accounts? For our use cases, I think every one is a business (and should have a business account), so I'll still explore it, but I can understand that'll be frustrating for those using this module for personal projects. I don't think it takes much to switch to a business account - both the band accounts I have access to on Instagram are business accounts, I think it is just a case of specifying that? Or at least it was when these were set up years ago. Given the maze of Meta requirements it wouldn't surprise me if you need to submit yearly accounts to get a business account now... Cheers, Chris
-
Hi @tomasanjosbarao, Thanks for letting us know. I'm not surprised! I'm going to investigate https://developers.facebook.com/docs/instagram-platform/instagram-api-with-instagram-login to see if this will be usable for the same purpose, and if it is, will try and get a new module together before 4/12/24! Cheers, Chris
-
Hi @DV-JF, I've just checked in on one of our sites using this module and its token has renewed again. I was definitely having issues with the FB/META/IG API stuff last week, so my preferred explanation is that there have been issues on that end that's prevented token generation and renewal. Are you still having an issue? Cheers, Chris
-
Hi, Some good news: we did manage to generate a User Token without app review, after setting a new application up from scratch. It's quite possible this bug is not connected to potential changes in the App Review policy, as initially feared. Similar issues have been reported: https://stackoverflow.com/questions/76473468/instagram-basic-display-api-cant-generate-access-token https://developers.facebook.com/support/bugs/185012584505063/ https://developers.facebook.com/community/threads/636065331832545/ We will keep an eye on this. Thanks, Mark
-
Hi, Initial findings aren't positive unfortunately. In our application, whenever I try to generate a User Token I get an Error message on the Instagram popup. I got a colleague to create an application from scratch in a FB dev account not associated with our business one, and we also got the same error when trying to generate a token. There's a message in the App Review section indicating that reviews are delayed for Instagram apps due to volume, which suggests that they've recently made it necessary to submit for App Review and there are a lot of people scrambling to get this done. We're going to investigate further and see if we can find some more information about this, perhaps getting confirmation through developer support and/or the community help. If this is what is going on, this module will still work for 'Live' (reviewed) applications, but my understanding is that the process is a likely a lot of jumping through hoops, and completely overkill for what the application is trying to achieve. It isn't something we'd be attempting willingly! Cheers, Chris
-
Hi @DV-JF, Unfortunately I suspect this may mean an end to this module being able to function. The impression I'm getting here is that the Basic Display API applications now need to be submitted for review/approval. This module took advantage of FB allowing development applications if they were created 'solely for the purpose of generating access tokens with the User Token Generator'. It really isn't clear however. When I try to generate an access token in the User Token Generator I get an error page on the Instagram pop-up window. I don't know whether this is because there's an issue on their end, because of the permissions thing you've highlighted, or something else. The next token renewal we have on a site using this module is in two weeks, so it'll be then before we come up against this issue. I'm going to ask a colleague to set up an application from scratch and see if he comes up against any issues, or other information that might shed some light on this. Will keep you updated on what we find. Cheers, Chris
-
Hi @Arklogic, Apologies, I'd decided many months ago now that developing this module in a way that would be robust enough for production (and listing on the modules directory) was just too complex. I thought I'd posted here to that effect. I see I did not. The latest code is here: https://github.com/nbcommunication/CloudflareAssets I think I did implement the page clone action, but did not implement anything for image editing in the admin, and have no plans to. While we are using this module on the website I'd developed it for, it is tailored for its use-case. Were I approaching the same development now, I'd be looking at using a CDN which would be significantly less work. Cheers, Chris
-
Hi @paulbrause, By when rendering do you mean $pageimage->render()? I don't think it is available to this implementation. If you are using the srcset method directly you can do $pageimage->SRCSET or $pageimage->HTTPSRCSET. Cheers, Chris
-
Hi, StackPath are removing their CDN product from the 22nd of November 2023 so I've removed this module from the directory. If anyone was using it you'll need to stop pretty soon! Cheers, Chris
-
Thanks @Stefanowitsch, That confirms that the issue is occurring when it tries to JSON encode the data. I'm happy for you to send the print_r() data via direct message if you want me to take a closer look. I also wonder whether trying to log serialize($data) would work, if so that output would be easier for me to work with. Cheers, Chris
-
Thanks, can you try changing the log to $this->log(json_encode($data)); instead?
-
Hi @Stefanowitsch, This is odd - getMedia() shouldn't be returning `false`, perhaps the json_encode() of the data is failing, this would explain the false return. Would you be able to edit the module to add a log before line 439? <php $this->log(print_r($data, 1)); if(count($data)) { // Line 439 //... } This output might help to determine why it is failing. Cheers, Chris
-
Hi @Stefanowitsch, Is the module itself logging anything? You've got your username in the working example - does adding it to the ajax one change anything? Cheers, Chris
-
Hi @Stefanowitsch, I'd start removing layers of complexity - does getMedia() return something outwith the ajax context? Is anything being logged by the module in Logs? Does the default user account appear in the module config? Cheers, Chris
-
Hi @Stefanowitsch, Are you using the javascript from the README? I think the UIkit ajax() function has changed so that could be the issue. You could try: fetch(window.location.href, { headers: { 'X-Requested-With': 'XMLHttpRequest', }, cache: 'no-store', }) .then(response => { if (response.ok) { return response.json(); } UIkit.util.addClass(instagram.$loading, 'uk-hidden'); console.error(response.statusText); // ERROR return []; }) .then(data => { // Hide spinner UIkit.util.addClass(instagram.$loading, 'uk-hidden'); if (!UIkit.util.isArray(data) || !data.length) return; // If no items do not render const items = []; data.forEach(item => { switch (item.type) { case 'VIDEO': items.push(instagram.renderItem(item.poster, item.alt, item.src)); break; case 'CAROUSEL_ALBUM': // If 4 or greater items, display a grid of the first 4 images with the rest hidden // Otherwise display the main image (no break, moves to default) if (item.children.length >= 4) { let out = ''; for (let i = 0; i < item.children.length; i++) { out += `<div${i < 4 ? '' : ' class=uk-hidden'}> ${instagram.renderItem(item.children[i].src, item.alt)} </div>`; } items.push(`<div class="uk-grid-collapse uk-child-width-1-2" data-uk-grid>${out}</div>`); break; } default: // IMAGE items.push(instagram.renderItem(item.src, item.alt)); break; } }); const count = items.length; if (count) { // Wrap all items with a div let out = ''; for (let i = 0; i < count; i++) { out += `<div id=instagram-item-${instagram.total + i}> ${items[i]} </div>`; } // Append items to the container UIkit.util.append(instagram.$el, out); // Attach scrollspy listener on last item of second last row if (count > 5) { UIkit.util.on(`#instagram-item-${instagram.total + count - 6}`, 'inview', () => instagram.get()); } // Update total instagram.total = instagram.total + count; } }); The next thing to do would be to try and get the full output that the script is returning. I'm not familiar enough with fetch() to know for certain but you could try console.log(response.text()); after the error log to see if that gives you it. My experience with the errors you've mentioned is that the first is caused by HTML being output/echoed before the JSON, and the second is usually caused by a deprecation notice being output. If you've got $config->debug enabled, try switching that off - if that works then check your logs to see what is triggering the notice and see if it can be resolved. Hope that helps, Chris
-
Hi @bdbdbd, It isn't the way I'd do it but if it is working for you then that's great. I'd probably add something that checks whether a resized version exists already prior to resizing. If it exists, perhaps update the file modified time if that's possible, and then have a bit of a script to remove images that are older that a set time period, could be anywhere from 1 day to 6 months depending on how often the feed is updated. Cheers, Chris
-
Hi @bdbdbd, The size() method needs to be called on a Pageimage object (an image saves to a Pageimages field) - it can't be called on an image directly. Saving the images to an image field would end up being quite tricky as you'd need to handle checking if the image already exists, and removing old images too. Honestly, I'd recommend just using the images from instagram, add width="300" height="n" to the <img> tag. I say height=n as this will need to be the height that the image would be if it were 300px wide - they aren't all square images. <?php $instagram = $modules->get('InstagramBasicDisplayApi'); // Get 10 images $images = $instagram->getImages(10); $counter = ''; foreach ($images as $image) { $counter = $counter + 1; $width = 300; $height = round(($image->height / $image->width) * $width); echo "<img src=$image->src alt='$image->alt' width=$width height=$height>"; } ?> If you need a 300px x 300px image grid, I'd recommend using a <div> with these dimensions and adding the image as a background-image (background-size: cover). Cheers, Chris
-
Hi, Now that the page-edit-redirects permission is in the latest master, I've redeveloped this module to list redirects in the system. I've also added a list of redirects present in the htaccess file (that match one of the httpHosts), and a field for filtering the tables. Cheers, Chris
-
Hi @snck, I'm just doing some testing on the module at the moment and was using this code as an example. Just wanted to let you know that 'allSets' should be set in srcset options alongside 'upscaling'. In this case, you wouldn't need to set upscaling as 'allSets' enables upscaling anyway. Cheers, Chris
-
Hi @Sanyaissues, It might be that this Textformatter isn't the best fit for your use case, but to hopefully solve your issue: json_decode() can return a stdClass object or an associative array. This module returns a stdClass object. I don't think you can use array_merge() on this (might be wrong, never tried it). To retrieve the field, modify it and save it, this should work: <?php $otherArray = []; $page->of(false); $array = json_decode($page->jsonfield, 1); // associative array $page->jsonfield = json_encode(array_merge($array, $otherArray)); $page>save(); // Or $array = json_decode($page->getUnformatted('jsonfield'), 1); // associative array $page->setAndSave('jsonfield', json_encode(array_merge($array, $otherArray))); Cheers, Chris