WordPress.org

Making WordPress.org

Opened 5 months ago

Last modified 4 weeks ago

#2907 assigned defect

Tagregator: Instagram items not getting pulled

Reported by: coreymckrill Owned by: xkon
Milestone: Priority: high
Component: WordCamp Site & Plugins Keywords: has-patch dev-feedback has-screenshots needs-testing
Cc:

Description

It looks like the Instagram API may have changed (quite some time ago, actually) and the plugin is no longer able to authenticate and get data. This was reported for WCUS 2016 and also here.

Here's an example of the request URL being sent currently and a relevant part of the response:

URL:

https://api.instagram.com/v1/tags/wcus/media/recent?client_id=XXXXXXX

Response:

[body] => {"meta": {"code": 400, "error_type": "OAuthAccessTokenException", "error_message": "The access_token provided is invalid."}}
[response] => Array
    (
        [code] => 400
        [message] => Bad Request
    )

The Instagram source class needs to be updated to comply with the changes to the API.

Attachments (4)

2907.diff (5.9 KB) - added by xkon 4 months ago.
Get Access Token and parse personal account
2907.1.diff (8.1 KB) - added by dipesh.kakadiya 4 months ago.
Added snapbox setting
2907.2.diff (8.6 KB) - added by xkon 4 months ago.
Final diff code cleanup
2907.3.diff (8.3 KB) - added by xkon 4 months ago.
cURL changed to wp_remote_post

Download all attachments as: .zip

Change History (16)

#1 @coreymckrill
5 months ago

  • Owner set to coreymckrill
  • Status changed from new to accepted

#2 @xkon
4 months ago

Hello @coreymckrill ! If the current users are not sandboxed ( as most where when the new API came out ) and they have the public scope on Instagrams Api then you can use the same url but by exchanging the ?client_id=XXXXXXX with an ?access_token=XXXXXX . Of course we have to find a way to get that access token either with cURL ( that would require a ton of redirects ) or with a little 'bypass' and a copy paste.

Unfortunately I don't have a public_scoped account to test this but I can create the whole process if you like so you can test it out with a normal account maybe?

In the case that the users are sandboxed we only get access to the users uploaded pics.

So I need some more info to try and get this done first :) .

Best regards,
Konstantinos

#3 @xkon
4 months ago

Updating, just wanted to inform you that I managed to make a seamless process through Tagregators Settings page to retrieve the access_token needed so I will have a patch uploaded really soon. I just need to run some extra tests.

Best regards,
Konstantinos

@xkon
4 months ago

Get Access Token and parse personal account

#4 @xkon
4 months ago

  • Keywords has-patch 2nd-opinion dev-feedback has-screenshots added; needs-patch removed

Okay so! After a lot of fiddling with instagrams new API I managed to make a really easy process on installing it's Access Token without having the user going back and forth on accepting urls etc.

As you will see in the Patch I have 2 different methods for getting the posts in tggr-source-instagram.php .

One is for the /users/self API call that also works when Sandboxed.
One for /tags/$/ that works ONLY if there is public access enabled in instagram.

Before commiting the patch you will have to alter the code again to whatever is more useful depending on what you need for the WordCamps.

If the apps created for WordCamps don't have public access enabled and they are sandboxed the tags public call will not work. Only the 'self' that is currently in code now will.

Now part from that for a weird reason that I cannot find out I'm always getting an error from:

[22-Jul-2017 11:26:20 UTC] PHP Notice:  Undefined index: consumer_key in tggr-source-twitter.php on line 152
[22-Jul-2017 11:26:21 UTC] PHP Notice:  Undefined index: consumer_secret in tggr-source-twitter.php on line 152

This is probably a different problem from the twitter settings but it causes the options to reset. I was not able to fix it I'm just informing you of this as well.

Maybe I'll make a new ticket about it ?

I'm marking this as 'has-patch' as the instagram problem is fixed but it needs good testing as I'm not sure how everything else works in there _ hahah.

This is a working screenshot using the /self/ api as I'm sandboxed so it reads only my own posts.

https://cldup.com/vePkTeFGeb.png

Best regards,
Konstantinos

This ticket was mentioned in Slack in #meta by xkon. View the logs.


4 months ago

@dipesh.kakadiya
4 months ago

Added snapbox setting

@xkon
4 months ago

Final diff code cleanup

#6 @xkon
4 months ago

2907.2.diff fixes all of Instagram API issues and adds 2 modes, Sandbox + Public.

The Settings page has been changed along with Instructions within to help the users.

Sandbox works with /self/ so it retrieves the photos of the account that is bound to the Client ( this does not work with #hashtags unfortunately ) and Non-Sandbox works with hashtags on all of Instagram as before.

Attention: Previous Patch to apply #2100 , Next patch to apply #3003 .

Best regards,
Konstantinos

Last edited 4 months ago by xkon (previous) (diff)

@xkon
4 months ago

cURL changed to wp_remote_post

#7 @xkon
4 months ago

2907.3.diff Updates the code to use wp_remote_post ( instead of cURL in 2907.2.diff ) as suggested by @coreymckrill and @sergey on the last ticket scrub in #meta-wordcamp .

Thanks both of you guys for pointing the way, it is actually much easier getting it done like this.

Best regards,
Konstantinos

Last edited 4 months ago by xkon (previous) (diff)

This ticket was mentioned in Slack in #meta-wordcamp by coreymckrill. View the logs.


3 months ago

#9 @coreymckrill
3 months ago

  • Keywords needs-testing added; 2nd-opinion removed

#10 @iandunn
4 weeks ago

  • Priority changed from normal to high

This ticket was mentioned in Slack in #meta-wordcamp by iandunn. View the logs.


4 weeks ago

#12 @iandunn
4 weeks ago

  • Owner changed from coreymckrill to xkon
  • Status changed from accepted to assigned

2907.3.diff looks to be in very good shape.

A few minor changes were requested in the bug scrub today, and after that @sergeybiryukov is planning to do a security review.

Note: See TracTickets for help on using tickets.