Jump to content
justb3a

Module: Instagram Feed

Recommended Posts

I kept running into the issue of self-invalidating access tokens and wanted the site's content editors to be able to handle the generation of new access tokens themselves. The module, however, limits those functions to superusers.

Could you change the module to check for the module-admin permission? It's ProcessWire's internal permission to check who can edit module configurations. It's deactivated by default and has to be created and assigned manually, so there's no additional risk or security concern. On a standard PW installation, it still only applies to superusers. However, it gives people the possibility to allow editors to generate access tokens.

So instead of

if ($this->user->isSuperuser()) {
  $href = self::API_URL_AUTHORIZE . '?' . http_build_query($request);
  $link = "<a href='$href'>" . __('get Access Token') . "</a>";
}

it's

if ($this->user->isSuperuser() || $this->user->hasPermission('module-admin')) {
  $href = self::API_URL_AUTHORIZE . '?' . http_build_query($request);
  $link = "<a href='$href'>" . __('get Access Token') . "</a>";
}

(There's a second check somewhere further down).

Thanks for considering this. I forked the module for now, but would much rather like this to be incorporated into master.

  • Like 2

Share this post


Link to post
Share on other sites
On 6/14/2018 at 9:06 AM, MarcoPLY said:

I still see this error in the log page every time some one visit the page:  [InstagramFeed]: No user 'xxx' was found. 

1

I have this same problem. Has anyone found a solution?

  • Like 1

Share this post


Link to post
Share on other sites

What is the recommedned way of getting another user's recently images? Am I right in saying in sandbox mode only the dev user can display their content, so it's needed to use the profile's account to setup the dev tokens etc, or is there a way of adding another username to the sandbox so I can query their images...

Bit confusing sorry, but I can only display my own images currently, no matter what I add to the module options.

Share this post


Link to post
Share on other sites

@benbyf

To save myself from the headaches, I only use scrapers anymore. No sandboxed accounts, no setup, no invalidated keys every two weeks. instagram-php-scraper has been working great so far. This is all there is to getting recent media of any user id or name:

$userid = env('INSTAGRAM_USER_ID');

$instagram = new \InstagramScraper\Instagram();
$account = $instagram->getAccountById($userid);
$username = $account->getUsername();
$latestMedia = $instagram->getMedias($username, 10);

foreach ($latestMedia as $media) {
	if ($media->getType() === 'image') {
		[...]
	}
}

 

  • Like 1

Share this post


Link to post
Share on other sites
Just now, benbyf said:

@d'Hinnisdaël holy smokes, so shocking to me that their APi is so bad that we have to resort to this sort of thing 😦

True. Many of the recent API updates are about privacy, which is a good thing. But the rollout was more than ideal. And I'd love to go the official way and use their API. But I get emails from clients every other week, asking about invalidated API tokens after they log in from a hotel wifi. And setting up API tokens is quite the hassle. So yeah, it's scrapers for now…

Share this post


Link to post
Share on other sites
Quote

 

To continuously improve Instagram users' privacy and security, we are accelerating the deprecation of Instagram API Platform, making the following changes effective immediately. We understand that this may affect your business or services, and we appreciate your support in keeping our platform secure.

These capabilities will be disabled immediately (previously set for July 31, 2018 or December 11, 2018 deprecation). The following will be deprecated according to the timeline we shared previously:

  • Public Content - all remaining capabilities to read public media on a user's behalf on December 11, 2018
  • Basic - to read a user’s own profile info and media in early 2020

For your reference, information on the new Instagram Graph API.

 

https://www.dropbox.com/s/tl5zgx9h7iormf8/Screenshot 2018-12-10 13.53.46.png?dl=0

 

Just seen this on the instagram developer portal. I had a quick play with the facebook API explorer but couldn't get it to work as wanted (just display another user's profile image). Think we'll need to get going with this as instagram is stopping support for it's own API 😦

Share this post


Link to post
Share on other sites

If someone has issues with generating an access token, I now have learned that it is important to include a language with the request for the access token:

https://www.instagram.com/oauth/authorize/?client_id=YOUR_CLIENT_ID&redirect_uri=http://page.dev/processwire/module/edit?name=InstagramFeed/&response_type=token&scope=public_content&hl=en

Source: https://stackoverflow.com/questions/55449162/https-api-instagram-com-oauth-authorize-api-login-error

So inside the "InstagramFeed.module", you should add 'hl' => 'en' in line 385:

<?php

$request = array(
    'client_id' => $this->clientId,
    'redirect_uri' => $redirect,
    'response_type' => 'code',
    'scope' => 'public_content',
    'hl' => 'en'
);

Regards, Andreas

  • Like 1

Share this post


Link to post
Share on other sites

hey together, for few days i have some trouble with this Module 

Quote

{"error_type": "OAuthException", "code": 400, "error_message": "Invalid scope field(s): public_content"}

I cant find the error. Also Updatet the language as @AndZyk told the post before.  Anybody else the same problem ? 

Share this post


Link to post
Share on other sites

Has nobody the same problem with this module? I think instagram changed the Api or something? 

Share this post


Link to post
Share on other sites

I used this to get the access token:

https://api.instagram.com/oauth/authorize/?client_id=CLIENT-ID&redirect_uri=https://www.yourdomainhere.co.uk/processwire/module/edit?name=InstagramFeed&response_type=code

1. Replace CLIENT-ID with your own CLIENT-ID code
2. I removed the trailing slash off suggested code on Processwire Module instructions

http://page.dev/processwire/module/edit?name=InstagramFeed/

Works OK for me, but I am getting error code "[InstagramFeed]: No user" too, but otherwise feed working OK.

Share this post


Link to post
Share on other sites
10 minutes ago, dab said:

I used this to get the access token:


https://api.instagram.com/oauth/authorize/?client_id=CLIENT-ID&redirect_uri=https://www.yourdomainhere.co.uk/processwire/module/edit?name=InstagramFeed&response_type=code

 1. Replace CLIENT-ID with your own CLIENT-ID code
2. I removed the trailing slash off suggested code on Processwire Module instructions


http://page.dev/processwire/module/edit?name=InstagramFeed/

Works OK for me, but I am getting error code "[InstagramFeed]: No user" too, but otherwise feed working OK.

Hmm Strange 

get still 

{"error_type": "OAuthException", "code": 400, "error_message": "Only response type \"code\" and \"token\" is allowed"}

OKAY IT WORKS. There was a empty space on the end from URL 
Thanks a lot 
 

  • Like 1

Share this post


Link to post
Share on other sites

For some reason the instructions above were not working for me. After some googling I found this tool https://instagram.pixelunion.net/.
f you're comfortable with trusting them, it works perfectly.

Share this post


Link to post
Share on other sites

After a little tweaking, I was able to get the access token back from Instagram. Using the post by @AndZyk as a starting point, I removed the following line from the module code:

'scope' => 'public_content'

Instagram returned the access token successfully.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By eelkenet
      Hi! I've created a small Inputfield module called InputfieldFloatRange which allows you to use an HTML5 <input type="range" ../> slider as an InputField. I needed something like this for a project where the client needs to be able to tweak this value more based on 'a feeling' than just entering a boring old number. Maybe more people can use this so I'm hereby releasing it into the wild. 
      EDIT: You can now install it directly from the Modules directory: http://modules.processwire.com/modules/inputfield-float-range/
       
      What is it?
      The missing range slider Inputfield for Processwire. 
      What does it do?
      This module extends InputfieldFloat and allows you to use HTML5 range sliders for number fields in your templates.
      It includes a visible and editable value field, to override/tweak the value if required.  
      Features
      Min/max values Precision (number of decimals) Optional step value (Read more) Optional manual override of the selected value (will still adhere to the rules above) Configurable rounding of manually entered values (floor, round, ceil, disable) Usage
      Clone / zip repo Install FieldtypeFloatRange, this automatically installs the Inputfield Create new field of type `Float (range)` or convert an existing `Float`, `Integer` or `Text` field. To render the field's value simply echo `$page->field` Demo
      A field with Min=0, Max=1, Step=0.2, Precision=2

      Field with settings Min=0, Max=200, Step=0.25, Precision=2

       
      Todo
      Make the display-field's size configurable (will use the Input Size field setting)  Hopefully become redundant  
      Changelog
      005 (current version)
      - Fix bug where the Inputfield would not work properly within repeaters / repeater matrices
      004
      - Make rounding of manually entered values configurable (floor, round, ceil or disable)
      - Fix small JS bug when the value-display field was not displayed
      - Update README
      003
      - Code cleanup, add some ModuleInfo data & LICENSE
      - Submit to PW Modules directory (http://modules.processwire.com/modules/inputfield-float-range/)
      002
      - Fix issue where setting the step value to an empty value created problem with validation
      - Make the display-field optional
      001
      - Initial release
       
      Thanks!
       
       
    • By Gadgetto
      Status update links (inside this thread) for SnipWire development will be always posted here:
      2019-10-18
      2019-08-08
      2019-06-15
      2019-06-02
      2019-05-25
      If you are interested, you can test the current state of development:
      https://github.com/gadgetto/SnipWire
      Please note that the software is not yet intended for use in a production system (alpha version).
      If you like, you can also submit feature requests and suggestions for improvement. I also accept pull requests.
      ---- INITIAL POST FROM 2019-05-25 ----
      I wanted to let you know that I am currently working on a new ProcessWire module that fully integrates the Snipcart Shopping Cart System into ProcessWire. (this is a customer project, so I had to postpone the development of my other module GroupMailer).
      The new module SnipWire offers full integration of the Snipcart Shopping Cart System into ProcessWire.
      Here are some highlights:
      simple setup with (optional) pre-installed templates, product fields, sample products (quasi a complete shop system to get started immediately) store dashboard with all data from the snipcart system (no change to the snipcart dashboard itself required) Integrated REST API for controlling and querying snipcart data webhooks to trigger events from Snipcart (new order, new customer, etc.) multi currency support self-defined/configurable tax rates etc. Development is already well advanced and I plan to release the module in the next 2-3 months.
      I'm not sure yet if this will be a "Pro" module or if it will be made available for free.
      I would be grateful for suggestions and hints!
      (please have a look at the screenshots to get an idea what I'm talking about)
       




    • By Robin S
      Another little admin helper module...
      Template Field Widths
      Adds a "Field widths" field to Edit Template that allows you to quickly set the widths of inputfields in the template.

      Why?
      When setting up a new template or trying out different field layouts I find it a bit slow and tedious to have to open each field individually in a modal just to set the width. This module speeds up the process.
      Installation
      Install the Template Field Widths module.
      Config options
      You can set the default presentation of the "Field widths" field to collapsed or open. Field widths entered into the Template Field Widths inputfield are only applied if the Edit Template form is submitted with the Template Field Widths inputfield in an opened state. "Collapsed" is the recommended setting if you think you might also use core inputs for setting field widths in a template context. You can choose Name or Label as the primary identifier shown for the field. The unchosen alternative will become the title attribute shown on hover. You can choose to show the original field width next to the template context field width.  
      https://github.com/Toutouwai/TemplateFieldWidths
      https://modules.processwire.com/modules/template-field-widths/
    • By adrian
      Tracy Debugger for ProcessWire
      The ultimate “swiss army knife” debugging and development tool for the ProcessWire CMF/CMS

       
      Integrates and extends Nette's Tracy debugging tool and adds 35+ custom tools designed for effective ProcessWire debugging and lightning fast development
      The most comprehensive set of instructions and examples is available at: https://adrianbj.github.io/TracyDebugger
      Modules Directory: http://modules.processwire.com/modules/tracy-debugger/
      Github: https://github.com/adrianbj/TracyDebugger
      A big thanks to @tpr for introducing me to Tracy and for the idea for this module and for significant feedback, testing, and feature suggestions.
×
×
  • Create New...