jonatan
Members-
Posts
90 -
Joined
-
Last visited
Everything posted by jonatan
-
Hm but shouldn't the caching be activated by default? It seems that it keeps using API calls... even within the same hour (3600 seconds)? – Implemented! Thanks!!! Nice! The module's updated now. So happy that you're on it! Can't wait to see what you come up with. Fingers crossed ?? All the very best, Jonatan
-
.. well ok just a minor update: With the API call restriction all maxed out I'm still getting this: Even though It's now $images = $instagram->getMedia(89); echo count($images) . "<br>" . print_r($images, 1); if(count($images)) { // Should avoid errors if there's no API response? foreach($images as $post) {
-
Cool! Thanks! ? Beautiful! Good to know! returns = ProcessWire\WireArray Object ( [count] => 89 [items] => Array ( [WireData:0] => 17909280568424854 [WireData:1] => 18121444630076805 [WireData:2] => 18099159694143228 [WireData:3] => 17883854266519759 [WireData:4] => 17854176994877232 [WireData:5] => 18055223719211749 [WireData:6] => 17865563617641437 [WireData:7] => 17853880954804716 [WireData:8] => 17914593256381694 [WireData:9] => 17860300231719969 [WireData:10] => 18017777869257089 [WireData:11] => 18019319182253256 [WireData:12] => 17847252025839832 [WireData:13] => 18036204127233891 [WireData:14] => 18122234449006372 [WireData:15] => 17917004923367534 [WireData:16] => 17854499389726168 [WireData:17] => 17852987293735761 [WireData:18] => 18086538826081818 [WireData:19] => 17866962334577860 [WireData:20] => 18120750871023389 [WireData:21] => 18009153073268946 [WireData:22] => 17849294431747827 [WireData:23] => 17901084034396625 [WireData:24] => 18094452511099675 [WireData:25] => 17847189019719414 [WireData:26] => 17854334599578989 [WireData:27] => 18107613148049776 [WireData:28] => 17909512951361240 [WireData:29] => 18104916640032595 [WireData:30] => 18105513970043998 [WireData:31] => 18066704767130489 [WireData:32] => 17881743565421950 [WireData:33] => 17957414410288932 [WireData:34] => 17957563855294908 [WireData:35] => 18061218313179032 [WireData:36] => 17845018267605780 [WireData:37] => 17860652530488128 [WireData:38] => 18008583064246673 [WireData:39] => 18087603124064192 [WireData:40] => 17849476189531758 [WireData:41] => 18046166611199390 [WireData:42] => 17848414930558047 [WireData:43] => 17971295623301665 [WireData:44] => 18089590891035103 [WireData:45] => 17872427797427060 [WireData:46] => 18087955213016216 [WireData:47] => 17844902065536403 [WireData:48] => 17844973564532788 [WireData:49] => 17859331249452842 [WireData:50] => 17849882830471152 [WireData:51] => 18075170245064821 [WireData:52] => 17942550430293736 [WireData:53] => 17966881903273180 [WireData:54] => 17965161424273612 [WireData:55] => 17898185860336217 [WireData:56] => 18041889235148605 [WireData:57] => 18075502267046552 [WireData:58] => 18007052467216993 [WireData:59] => 17886482302359660 [WireData:60] => 17871858511389658 [WireData:61] => 17869022899360249 [WireData:62] => 18036545284117191 [WireData:63] => 17872542331346319 [WireData:64] => 18008081158196147 [WireData:65] => 18050794615051665 [WireData:66] => 17861485243368787 [WireData:67] => 17865307225357563 [WireData:68] => 18039611095079744 [WireData:69] => 18048228658019001 [WireData:70] => 17986084408204328 [WireData:71] => 17873339755334078 [WireData:72] => 17880649264316699 [WireData:73] => 18019533538130038 [WireData:74] => 18020855698187180 [WireData:75] => WireData [WireData:76] => WireData [WireData:77] => WireData [WireData:78] => WireData [WireData:79] => WireData [WireData:80] => WireData [WireData:81] => WireData [WireData:82] => WireData [WireData:83] => WireData [WireData:84] => WireData [WireData:85] => WireData [WireData:86] => WireData [WireData:87] => WireData [WireData:88] => WireData ) ) A lot... Out of the 80 showed posts, 46 are carousels. Hm.. But I guess that showing carousels shouldn't be an issue? ? Shouldn't it be problemfree to display all of the users carousels? – Thank you for clearing that up!! I've adapted my code to your version ? Goodnight from Denmark ? ??
-
@nbcommunication Awesome!! I'll be excitedly waiting ☺️ I implemented: $images = $instagram->getMedia(89); if(count($images)) { foreach($images as $post) { ... } And It's works. And I suppose that the page would render fine now even with the API being maxed out. But I'm still getting "empty slots..." ? And also.. I'm getting these PHP notices from tracy: Referring to this line in the .module: – And this: ❔I'm not sure about the first one about the caption, but maybe that's because there's no caption for some of the posts? And I guess since it's just a notice it doesn't need fixing? ❔But about the other errors regarding undefined offsets... It counts from offset 75 (meaning actually offset 76 counting including offset 0 as one). – I guess this is actually basically just saying that the last posts – post nr 77 to post nr 80 – which for some reason aren't being pulled (again, why aren't they...? ?) (out of the requested amount of posts (89)) are not there so it just displays an empty slot. Can I make like a " case : break; "? perhaps differently (properly) formatted? Or something smarter? Would that work to prevent generating empty slots? Thank you again!! All the very best, Jonatan
-
Thank you so much already Criss @nbcommunication! And thank you for such a quick reply! I'm so surprised by the helpfullness of this forum! I really appreciate that you're helping out that much! ?? – Thank you! That's of course just all that's needed! ? – I did consider whether I should just display fewer items - like the standard 24 fx - and hence make it easier, but I really want the page to have a wholehearted instagram feed feel... I can't really figure out how it'd had to be done though, implementing a "lazyload"... so that I don't get all 80 or whatever images served all at once... Should I try to go for something like on page load making the php request, say, 9 posts, then when the user scrolls to the bottom, make it call for 9 more? Reg cachetime, – it seems it's already set to 3600 in the .module? ? Or is it another cachetime you mean? Thank yo again! All the very best, Jonatan
-
Awesome @nbcommunication (Criss)! Thanks a lot for all your effort! ? It has really helped me out! And I'm sure it'll help others as well! No worries about the data-width though, it's working without it actually ? But good to know though about the oEmbeds! I've just checked out your nbcommunications website btw, and it's really neat! ? Here's my own take on it (much less sophisticated and uglier ?). But it's because I'm using Bootstrap 4 and Fancybox that I tried to adapt it to that: <?php foreach($images = $instagram->getMedia(89) as $post) { switch($post->type) { case "VIDEO": echo" <div class='col-4 p-3 pics'> <a data-fancybox='gallery-ig' data-height='600' data-caption='{$post->href}' href='{$post->src}' > <div style='background-image: url({$post->poster})' class=' pics'> <div class='overlay-video-icon'></div> </div> </a> </div> "; break; case "CAROUSEL_ALBUM": echo" <div data-interval='3000' class='carousel slide carousel-fade col-4 p-3 pics' data-ride='carousel' id='_{$post->id}'> <div class='carousel-inner'> "; $post->children->each(function($post) { echo" <a class='carousel-item' data-fancybox='gallery-ig' data-height='600' data-caption='{$post->href}' href='{$post->src}' > <div style='background-image: url({$post->src})' class=' pics'></div> </a> "; }); echo" <a class=\"carousel-control-prev\" href=\"#_{$post->id}\" role=\"button\" data-slide=\"prev\"> <span class=\"carousel-control-icon-bg\" aria-hidden=\"true\"></span> <span class=\"carousel-control-prev-icon\" aria-hidden=\"true\"></span> <span class=\"sr-only\">Previous</span> </a> <a class=\"carousel-control-next\" href=\"#_{$post->id}\" role=\"button\" data-slide=\"next\"> <span class=\"carousel-control-icon-bg\" aria-hidden=\"true\"></span> <span class=\"carousel-control-next-icon\" aria-hidden=\"true\"></span> <span class=\"sr-only\">Next</span> </a> </div> </div> "; break; default: // IMAGE echo" <div class='col-4 p-3 pics'> <a data-fancybox='gallery-ig' data-height='600' data-caption='{$post->href}' href='{$post->src}' > <div style='background-image: url({$post->src})' class=' pics'></div> </a> </div> "; break; } } ?> <script type="text/javascript"> $(document).ready(function(){ $('.carousel').each(function(){ $(this).find('.carousel-item').eq(0).addClass('active'); }); }); </script> Resulting in this: Sasha IG Feed 720p.mp4 – Images as simple square thumbs, – videos the same but with a video-overlay (dark transparent black box with a play icon), – and the image carousels as a small carousel / slideshow. – That's actually also quite good.. Except a feeeew things that you could perhaps help me with... In general the performance of my instafeed page is awful ?. It takes an extremely long amount of time to load! ⏱️? – About 30 seconds! I am realizing though that I'm also making a large amount of post requests : $instagram->getMedia(89) But I can see that what is different from my poorly noob-interpreted version of your php code is that you collect it all into an array, and then serve it all from that array, where as I just echo"..."; away on everything... (as arrays still isn't quite my speciality...) ❔– Would it performance wise make any difference to use your method of first collecting it all into an array, and then serving it all by rendering all the items in that array, as you do it?... Which also leads me this... Pagination (& lazyload?) I can see that the API has some built in pagination: https://stackoverflow.com/questions/59814442/instagram-basic-display-api-pagination | https://developers.facebook.com/docs/instagram-basic-display-api/reference/media/children | https://developers.facebook.com/docs/graph-api/using-graph-api#paging – ❔ But with my very sad php skills I can't figure out how to actually implement it? My goal is that I wish to serve all and every post available from the user (currently counting 80 posts) as you scroll down the page... But of course here pagination would come into the picture. Could you maybe help me come up with a solution so that when you reach the end of the page the next (9 perhaps) posts would be loaded... (some kind of lazy load? ) Much like on Instagram itself: ig scroll down 720p.mp4 – I suppose this pagination / lazy load integration would perhaps also help out a lot of others wishing to display the whole IG feed? Maybe it'd be handy to have in the module's README as well? ? Also there's something I can't explain.. I'm getting some: Empty slots I'm requesting 89 posts. (Because I read on stack overflow that the maximum request is 90.. that might have changed though?) But there are only 80 posts all in all. The API feed is only showing 75 posts though. – Which is also really weird? – Can't figure why so... But for the remaining (89-75 = ) 14 posts it shows empty slots:... empty slots.mp4 ❔– Why is that? Do you have any idea? I supposed that if there weren't actually as many posts to get as requested it would only get the available amount of posts, within the requested limit? And one more quite crucial thing... CRAZY API load amounts... Before IG feed page Load: gr:get:Media/children: 1331 gr:get:User:Media: 47 (it seems it's still showing yesterdays request-count?) After one IG feed page load: gr:get:Media/children: 669 gr:get:User:Media: 38 – 60%remaining One reload: gr:get:Media/children: 703 gr:get:User:Media: 38 – 37%remaining One more reload: gr:get:Media/children: 739 gr:get:User:Media: 38 – 21%remaining One more reload: gr:get:Media/children: 779 gr:get:User:Media: 38 – 0%remaining One more reload: gr:get:Media/children: 855 gr:get:User:Media: 38 – 6%remaining ❔ ... It says the total number of calls = 200 * number of users... Shouldn't I worry about this? I mean if I after only 5 page loads have used my quota... That doesn't seem to be enough for a properly functioning live website with multiple users?... And one more thing... Media_count <?php $data = array('username'=>''); $account = $instagram->getUserAccount($data["username"]); $username = isset($account["username"]) ? $account["username"] : ""; $data = array('media_count'=>''); $mediacount = $instagram->getUserAccount($data["media_count"]); $postsnum = isset($mediacount["media_count"]) ? $mediacount["media_count"] : ""; ?> <div class="col-12 text-center mb-3"> <a href="https://instagram.com/<?php echo $username;?>/" target="_blank" class="marked"><h3 class="marked my-5 instalink"> <?php echo "@" . $username;?></h3> </a> <h5 class="marked-dark"><?php echo $postsnum?> POSTS / OPSLAG </h5> </div> ❔I'm getting the media_count from the module... to show the number of user posts on the page to give it more of an insta feel. When I loaded the page though it ($postnum) hadn't updated to the current amount (80 instead of 78, because the user has added a post 4 hours before I reloaded the page). I went to the processwire admin and the module page and then there it was updated... Then I reloaded the page and it was updated.. Was that only due to the module updating it when visiting the modules page in the processwire admin that it updated it though? – In short: can I rely on $mediacount = $instagram->getUserAccount($data["media_count"]); to fetch the updated post count (without having visited the module page in pw) ? The reason why I'm relying on the module in the first place and not just $profile = $instagram->getProfile("username"); is actually to save on API calls as, as you've seen above, they seem to extremely fast become used up... ? Also talking about API calls quickly being used up... PHP error I'm getting this when critical error if the php tries to get media but the api doesn't answer due to "maxed out credit": ❔How could I prevent that? – And make the page still functional if the API doesn't answer I know that was a lot of questions! – Probably some of it is due to a lack of a lot of basic php knowledge... But if you could help me out it would simply be amazing! And I'm sure others using the module, as php-handicapped as me, could probably benefit from some of the answers as well. Thanks a thousand times in advance! ☺️☺️☺️ All the very best, Jonatan
-
Show data in locked custom field – 'Locked' field not showing
jonatan replied to jonatan's topic in General Support
Thanks @bernhard! Really seems like an interesting read! ☺️- 8 replies
-
- locked field
- collapsenolocked
-
(and 3 more)
Tagged with:
-
Module Module: RuntimeMarkup Fieldtype & Inputfield
jonatan replied to kongondo's topic in Modules/Plugins
Hmm... When I try to uninstall the module I get this error... ? ? l EDIT: // Hmm... I don't know what changed but after having refreshed my modules the uninstaller worked (Resolved) All the best, Jonatan -
Show data in locked custom field – 'Locked' field not showing
jonatan replied to jonatan's topic in General Support
Thank you @bernhard!! ☺️ – Tested! – Heureka! That worked as well! : I just simply couldn't figure out that the 'value' was all that needed haha. But it works perfectly fine!- 8 replies
-
- locked field
- collapsenolocked
-
(and 3 more)
Tagged with:
-
@gowthamg Do you just need to simply show the images from a user? Because in that case you only need the Instagram Basic Display product (https://developers.facebook.com/docs/instagram-basic-display-api/) (no need to submit anything to fb and no need to provide a website adress). Did you follow these steps? : https://github.com/nbcommunication/InstagramBasicDisplayApi Facebook for Developers: Add new fb app Add instagram as a product for your app Go to your app > Products > Instagram > Basic Display and scroll down to "User Token Generator" Add Instagram Tester Approve the tester inviter on the instagram profile Click generate token Processwire Instagram Basic Display API: Go to your module, click 'Add an Instagram user account Fill in the username and the generated token And then you should be able to use the api? Hope it may help, Best, Jonatan
-
Show data in locked custom field – 'Locked' field not showing
jonatan replied to jonatan's topic in General Support
@adrian Thank you so much!!!!! ?☀️??? And thank you for such an amazing response time! - Done! - Worked like a charm!!!! Strongly back on the I-love-processwire-and-think-it-is-so-amazing-train! ??? ✅ Solution: Installed RuntimeMarkup Fieldtype module, made a new field with that type: DETAILS > : Edited runtime php file: site/templates/instagramaccountid.php: <?php namespace ProcessWire; $instagram = $modules->get("InstagramBasicDisplayApi"); $data = array('username'=>''); $account = $instagram->getUserAccount($data["username"]); $username = isset($account["username"]) ? $account["username"] : ""; $at_instausername = "@" . $username; echo$at_instausername; ?> Result: One piece of beautifully dynamically called data shown in as sweet plain text in the defined field in the template: Could be really cool though if this kind of custom field would maybe become integrated in the core? As well as an "locked / unlocked" option for all fields? Thanks again! All the best, Jonatan- 8 replies
-
- 1
-
- locked field
- collapsenolocked
-
(and 3 more)
Tagged with:
-
Show data in locked custom field – 'Locked' field not showing
jonatan replied to jonatan's topic in General Support
Oh, and one more thing, Also, I'm wondering why there's no "Open + Locked (not editable)" option? Is that an error? ☺️- 8 replies
-
- locked field
- collapsenolocked
-
(and 3 more)
Tagged with:
-
collapsedNoLocked field not showing Hi all, ☺️ I'm a 21 years old ??, danish ??, hobby-designer-and-web-stuff-maker and very excited and eager processwire beginner, or "noob" ? if you wish. So far I've been fascinated by the very satisfyingly simple and yet powerfull magic ✨ of PW (once you get the hang of it) and the awesome feeling of the strong PW community ??☀️❤️! The huge work done by @ryan and all of the other amazing PW people is just so inspiring! I actually really have a hard time understanding why Processwire isn't the most used CMS in the world... or at least just a way more commonly known one! But now I've encountered a small bump on the road and I'd lovingly appreciate if one of you lovely PW forum members could maybe help me out! ❓Problem: So I have a problem with the collapsed-constant: https://processwire.com/api/ref/inputfield/#pwapi-methods-collapsed-constants - It's not showing my field when I apply it. (I've funnily enough found this old git pull from 2014 which documents the "Locked" state being added as a field -> input -> visibility option: https://github.com/ryancramerdesign/ProcessWire/pull/457 – it also shows the relevant code implementations to the core) ? What I wish to do: is to ? display some data from a ? module (InstagramBasicDisplayApi) in the ⌨️ page editor when editing a page ("About me") using the template (About.php) - So the only possible way to do that as far as for what I've been able to come up with with my restricted PW (end eh.. php) –knowledge was to add a custom field type to the (About.php) template... I've set up a custom field using https://modules.processwire.com/modules/mystique/ : site/modules/configs/Mystique.php: <?php namespace ProcessWire; $modules = wire("modules"); $instagram = $modules->get("InstagramBasicDisplayApi"); $data = array('username'=>''); $account = $instagram->getUserAccount($data["username"]); $username = isset($account["username"]) ? $account["username"] : ""; $at_instausername = "@" . $username; /** * Resource : Instagram account */ return [ 'title' => __('Instagram account'), 'fields' => [ 'window_title' => [ 'label' => __(' '), 'type' => Mystique::TEXT, // or InputfieldText 'useLanguages' => true, 'collapsed' => '0', 'placeholder' => __($at_instausername), ] ] ]; - Basically: I'm getting the instagram-username, pulling it from the module "InstagramBasicDisplayApi", And then I'm using it as the 'placeholder' value for the field, resulting in this: - Which is actually what I want... almost... – The thing is, I would like it to be locked, so that it's not possible to overwrite the 'placeholder' value, but so that the inputfield actually does not take any input but just informatively displays the data... so what I do is that I just change 'collapsed' to '7' = 'collapsedNoLocked': 'collapsed' => '7', , right, and that would be it? But unfortunately no... When I do I get this: - I can't figure out why? I'd supposed that the 'placeholder' value would just show, but non-editable? A "workaround" is to just set it to back to 0, then manually type in "@sasha_lindegaard" and then press save, and then set it to 7, and I have what I want: - But that's not really what I wish, as it displays the data (the instagram username) statically (from what I've typed into the field and have saved) and not dynamically (from the instagram module database) as wished for... – also, it's still collapsable? Why so?... ? Any ideas for how I might get my "INSTAGRAM" field to display the username from the instagram module's database dynamically, not as editable placeholder text in a editable/open input field but just as non-editable/locked text? I hope that I've made my problem clear enough but if I've failed to provide enough info please don't hesitate to request for more! ? Thanks a thousand times in advance! All the best, Jonatan R.
- 8 replies
-
- locked field
- collapsenolocked
-
(and 3 more)
Tagged with:
-
Thank you so much @nbcommunication! It's an awesome and very needed module! Very useful! ? Only minor thing: Perhaps add to the documentation (which is great otherwise!): $instagram = $modules->get("InstagramBasicDisplayApi"); – That ofc needs to be added initially. And I also just thought: Could you also maybe in the readme show an example of pulling an array of both images, image carousels and videos (basically everything the user has posted, of all the types) and showing them all one after the other chronologically, but of course differently formatted depending on if it's an img, video or img carousel ? And, Does it support all https://developers.facebook.com/docs/instagram/embedding/#sample-request properties? Fx video width? It seems that if I call $videos = $instagram->getVideos(); foreach($videos as $video) and try to use data-width='{$video->width}' it doesn't work? All the best, Jonatan