Jump to content

Module: Instagram Feed


justb3a

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
Link to comment
Share on other sites

  • 1 month later...
  • 2 weeks later...

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.

Link to comment
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 2
Link to comment
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…

Link to comment
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 ?

Link to comment
Share on other sites

  • 4 months later...

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
Link to comment
Share on other sites

  • 3 months later...

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 ? 

Link to comment
Share on other sites

  • 3 weeks later...
  • 4 weeks later...

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.

Link to comment
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
Link to comment
Share on other sites

  • 5 months later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...