justb3a Posted March 31, 2016 Author Share Posted March 31, 2016 — Is there a way to update the cache every 60 seconds? Nope. This module uses the built-in WireCache functionality which defines the following caching periods: const expireNow = 0; const expireHourly = 3600; const expireDaily = 86400; const expireWeekly = 604800; const expireMonthly = 2419200; — Is it possible to access the "high_resolution" endpoints, even though they aren't already implemented in instagram API (files are there but not implemented)? This isn't possible, this module just uses the existing instagram endpoints. 2 Link to comment Share on other sites More sharing options...
Tanky Posted March 31, 2016 Share Posted March 31, 2016 Okay, thanks for the explanations. Link to comment Share on other sites More sharing options...
iNoize Posted April 20, 2016 Share Posted April 20, 2016 Hello again, how can i get the {media-id} from the current image ? https://www.instagram.com/developer/endpoints/comments/ I want to get the comments but in the standard feed there is no media-id or comments in the array ? What i have to do to get the comments ? Thanks Link to comment Share on other sites More sharing options...
justb3a Posted April 21, 2016 Author Share Posted April 21, 2016 Hi, I did just a short look at the instagram api and both implemented endpoints seem to submit a media-id inside the returned array. If this is not the right one, if have no idea as well { "data": [{ "comments": { "count": 0 }, ... "type": "image", "id": "22721881", ... }] } Link to comment Share on other sites More sharing options...
gebeer Posted April 29, 2016 Share Posted April 29, 2016 My app is kind of a social wall that is running for days/weeks on end and I would like to automate the retrieval of a new access token. Problem: we never know when Instagram might decide to revoke the access token. Once the old one has been revoked, the Instagram API will return error_type=OAuthAccessTokenError. Whenever the response contains this, I would like to generate a new one automatically and save it to the module settings. Looking at the getCode() method, it requires superuser priviliges to get the access token because the redirect URL for getting the code from Instagram lies within the PW admin. So I tink I need to provide a publicly accessible redirect URL to handle the process of aquiring the new access token. Am I heading in the right direction here? (Sorry if this may sound like a silly question. But it is the first time for me working with the Instagram API). EDIT: Sorry, I should have read through the module code more carefully. I think, all it takes to automate retrieval of new access token is modifications to1. sendRequest method to handle authorization failure and get the new accesstoken2. getCode method to allow handing back the URL for code retrieval when not logged in as superuser3. have a module setting to cater for automatic update of access token I will give it a shot and report back here how it goes. 2nd EDIT: After doing quite some digging and reading carefully through the Instagram API docs and usage policy, I found that the API is not supposed to be used for automated aquisition of access tokens the way I was originally planning it and the way I can do it eg with Twitter API. Instagram is pretty restrictive and they clearly state in their Platform Policy Do not abuse the API Platform, automate requests, or encourage unauthentic behavior. This will get your access turned off. Various sources state that their access token has been working for quite a long time (up to 3 years). So I don't worry too much about the access token being revoked during the time my social wall will be up. Anyways, I will cater for the rare case that the access token is invalid at some point in time. I will extend this great module so that the superuser gets notified by email when authentication problems occur during requests to the API. Then they can do a manual refresh of the access token through the link in the module admin interface. Link to comment Share on other sites More sharing options...
gebeer Posted May 1, 2016 Share Posted May 1, 2016 To retrieve tagged media with $media = $modules->get('InstagramFeed)->getRecentMediaByTag('mytag') I had to add scope=public_content to the url for getting the code in the getCode() method: $request = array( 'client_id' => $this->clientId, 'redirect_uri' => $redirect, 'response_type' => 'code', 'scope' => 'public_content' ); After that I had to click the 'get Access Token' link again and renew the permissions for the app. Otherwise I always received an empty result. In the Instagram API docs they state that the public_content scope is required. With the module as is now, it only gets the basic permissions in the getCode() method by omitting the scope parameter. (more about scopes in the API docs) Can anyone confirm that they have successfully received results for the getRecentMediaByTag() call without adding scope=public_content to the 'get Access Token' link url? Link to comment Share on other sites More sharing options...
iNoize Posted May 5, 2016 Share Posted May 5, 2016 Hello, seems to be the right one. Hi, I did just a short look at the instagram api and both implemented endpoints seem to submit a media-id inside the returned array. If this is not the right one, if have no idea as well { "data": [{ "comments": { "count": 0 }, ... "type": "image", "id": "22721881", ... }] } But how to make a call now ? From the Module ? I treid do realize it self but my php are not enough for this currently. Link to comment Share on other sites More sharing options...
gebeer Posted May 7, 2016 Share Posted May 7, 2016 @iNoize To make a call, you need to have the module installed and gone through the process of generating your access token (which is desribed in the module howto). Then you can make calls from anywhere in yoru templates: $instagram = $modules->get('InstagramFeed'); // load the module $userMedia = $instagram->getRecentMedia(); // get media of your user Then you should have a look at the PHP example to see how you can access values inside $userMedia. $userMedia is just an example name. You can call that whatever you want. in the PHP example it is called $feed. $feed is an array of the media for that instagram user. You need to loop through that array in a foreach to access the contained media items and extract their properties for display. Link to comment Share on other sites More sharing options...
iNoize Posted June 2, 2016 Share Posted June 2, 2016 @gebeer thanks for your advice it works for me like in the examples but what i need is the last comments self, if put out the whole feed <pre> <?php vardump($feed); ?> </pre> there are no comments in the array ? So my question was is it possible with this module ? or is it possible to rewrite a litle this module ? my php skills are not so good that i could do it self. Link to comment Share on other sites More sharing options...
AvaJohnson Posted June 3, 2016 Share Posted June 3, 2016 Thanks for the Module. Tested recently and worked well on me. Now its fine and tested on Instagram support. Thanks ! Link to comment Share on other sites More sharing options...
gebeer Posted June 3, 2016 Share Posted June 3, 2016 @iNoize getting comments is not implemented in the module. One would have to extend the module code to call the comments endpoint for every media object. Sorry, but I don't have the time for this right now. Link to comment Share on other sites More sharing options...
justb3a Posted June 3, 2016 Author Share Posted June 3, 2016 @iNoize getting comments is not implemented in the module. One would have to extend the module code to call the comments endpoint for every media object. Sorry, but I don't have the time for this right now. Thanks for testing. Using this endpoint you just get the number of comments, not the comment itself. ["comments"]=> array(1) { ["count"]=> int(1) } Link to comment Share on other sites More sharing options...
justb3a Posted June 3, 2016 Author Share Posted June 3, 2016 Here you go: new InstagramFeed version 1.0.0 add required scope public_content to retrieve tagged media with getRecentMediaByTag('tag') (thanks @gebeer) add ProcessWire 3.x compatibility add endpoint to get a list of recent comments on a media object: getRecentComments($media) Example: <?php $feed = $modules->get('InstagramFeed')->getRecentMedia(); ?> <div class="instagram> <?php foreach ($feed as $media): ?> <?php if ($media['type'] === 'image'): ?> <a href="<?=$media['link']; ?>" class="instagram-item"> <img src="<?=$media['images']['thumbnail']['url']; ?>" alt=""> </a> // display comments <?php $comments = $modules->get('InstagramFeed')->getRecentComments($media); ?> <?php if ($comments): ?> <ul> <?php foreach ($comments as $comment): ?> <li><?=$comment['text']?></li> <?php endforeach; ?> </ul> <?php endif; ?> <?php endif; ?> <?php endforeach; ?> </div> A comment ($comment in the example above) contains the following data: "created_time": "1280780324", "text": "Really amazing photo!", "from": { "username": "snoopdogg", "profile_picture": "http://images.instagram.com/profiles/profile_16_75sq_1305612434.jpg", "id": "1574083", "full_name": "Snoop Dogg" }, "id": "420" 7 Link to comment Share on other sites More sharing options...
iNoize Posted June 14, 2016 Share Posted June 14, 2016 @justb3a Thanks a lot but something goes wrong there in your example ? Link to comment Share on other sites More sharing options...
justb3a Posted June 15, 2016 Author Share Posted June 15, 2016 @justb3a Thanks a lot but something goes wrong there in your example ? Ah, thanks for your hint. There was a missing opening `<?php` tag. I corrected the example above as well as the Github readme. Link to comment Share on other sites More sharing options...
iNoize Posted July 4, 2016 Share Posted July 4, 2016 On 15.6.2016 at 11:24 AM, justb3a said: Ah, thanks for your hint. There was a missing opening `<?php` tag. I corrected the example above as well as the Github readme. Hello, i get alway NULL or Array(0) dont really work ? have you tried your code ? maybe is something wrong in the access token ? Link to comment Share on other sites More sharing options...
LostKobrakai Posted July 4, 2016 Share Posted July 4, 2016 Did you read this one https://www.instagram.com/developer/? Since 1. of June one can only access the latest 20 images of up to 5 sandbox users without going through a app review by Instagram's staff. Hashtags will also only show media of those users in sandbox mode. Link to comment Share on other sites More sharing options...
kaya1923 Posted July 4, 2016 Share Posted July 4, 2016 Working with iNoize, i found a way to fix this problem -> instagram.pixelunion.net/ Link to comment Share on other sites More sharing options...
justb3a Posted July 5, 2016 Author Share Posted July 5, 2016 17 hours ago, iNoize said: have you tried your code ? No. Never. Should I? From time to time I dream about some code someone might need and put it inside a module Thanks @LostKobrakai for pointing out the sandbox mode. more about sandbox mode 2 Link to comment Share on other sites More sharing options...
alexm Posted October 5, 2016 Share Posted October 5, 2016 I'm getting the following warning when trying to render the feed: Warning: constant(): Couldn't find constant WireCache::expireWeekly in/path/to/public_html/site/assets/cache/FileCompiler/site/modules/InstagramFeed/InstagramFeed.module on line 286 I am running PW version 3.0.33. Any thoughts what might be causing this? Thanks for the help! Link to comment Share on other sites More sharing options...
justb3a Posted October 6, 2016 Author Share Posted October 6, 2016 @alexmercenary I published a new version 1.0.1 which adds namespace support. 3 Link to comment Share on other sites More sharing options...
alexm Posted October 7, 2016 Share Posted October 7, 2016 @justb3a thank youuuuu! Link to comment Share on other sites More sharing options...
alexm Posted October 7, 2016 Share Posted October 7, 2016 Hm... I still seem to be having issues. I'm getting: Warning: Invalid argument supplied for foreach() When trying to loop the instagram posts. I'm trying to get posts by method getRecentMediaByTag Any thoughts? Link to comment Share on other sites More sharing options...
justb3a Posted October 7, 2016 Author Share Posted October 7, 2016 Could you please output the variable before starting the foreach loop (var_dump($feed);). I guess it's empty. Are you sure that the generation of the access token has gone right? Link to comment Share on other sites More sharing options...
alexm Posted October 7, 2016 Share Posted October 7, 2016 I get NULL when I do a var_dump. I have a Client ID and Secret, then saved the page. Then came back and then clicked get access token and re-saved. I've just tried clearing the access token, regenerating the Client secret saving the page and then getting the access token again but I'm still getting NULL. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now