Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document vs Oembed / Instagram blocked #357

Closed
reflexxion opened this issue May 25, 2020 · 11 comments
Closed

Document vs Oembed / Instagram blocked #357

reflexxion opened this issue May 25, 2020 · 11 comments

Comments

@reflexxion
Copy link
Contributor

Hi,

I'm using v4 for resolving our embeds.
Mainly (probably only) we are using embeds which does provide an oembed endpoint.
So we've a big overhead by first getting the main document of that "url".

https://github.com/oscarotero/Embed/blob/master/src/Embed.php#L23-L24

I think it'll be a big benefit to first check if that url does provide an oembed endpoint (detectEndpointFromProviders) and if so to only query that specific api endpoint.

Is there any build in way that I'm missing?

Regards

@oscarotero
Copy link
Owner

Hello.
This initial request checks the url status and resolve possible redirects. For example, a user can share a short link such https://t.co/4DK3Jc2BTt that must be resolved to the final url.

The way Oembed is detected is by priorizing the links found in the document and then the detectEndpointFromProviders (https://github.com/oscarotero/Embed/blob/master/src/OEmbed.php#L55) The main reason is that the urls in the document are more reliable because are provided directly by the site. The other values are hardcoded in a php array (https://github.com/oscarotero/Embed/blob/master/src/resources/oembed.php) and can become obsolete.

@reflexxion
Copy link
Contributor Author

reflexxion commented May 25, 2020

Ok, I understand.

Now we've an issue with instagram.
Instagram changed something (or blocked us) so that they are now redirecting a non matching URL.
The url was something like https://www.instagram.com/accounts/login?next=ORIGINAL_URL. (and seems to be some blocking)
This stopped oembed from working for instagram.

@oscarotero
Copy link
Owner

Mmm, I see.
FYI, instagram works fine in localhost, but not in my server (Example)

Perhaps it's because instagram detects too many requests from this ip?

@reflexxion
Copy link
Contributor Author

Yeah, that's the same issue I had.
Any idea how we can solve this?
I did a workaround on my side by only crawling the oembed api for certain providers.
But would be great to have this in the library.

@reflexxion reflexxion changed the title Document vs Oembed Document vs Oembed / Instagram blocked May 27, 2020
@oscarotero
Copy link
Owner

I made some changes to check the oembed endpoint not only with the final url, but also with the inital url and seems to work fine.

@nteath
Copy link

nteath commented May 29, 2020

Any chance this could be implemented in version 3 as well ?

Update for anyone using version 3.
What I did as a temporary solution is I changed the Instagram provider (oembed provider) to check the response's url, if it contains 'accounts/login' I use the getStartingUrl() method instead of the getUrl().

@oscarotero , Is there any way to use a custom oembed Provider instead?

@oscarotero
Copy link
Owner

New versions released with fixes for v4 and v3

@zwan2
Copy link

zwan2 commented Jul 1, 2020

  1. Still not works for remote server (embed v3.4.7, PHP v7.3 remote server)
  2. Shortend url can't works even in v3 demo site (https://oscarotero.com/embed3/demo/)
    (Example: http://instagr.am/p/CAkFeVZAgB1/)

@reflexxion
Copy link
Contributor Author

reflexxion commented Jul 1, 2020

Hey @zwan2,

I think this is due to a "not registered" URL pattern for "instagr.am" -> https://github.com/oscarotero/Embed/blob/v3.x/src/Providers/OEmbed/Instagram.php#L10

@davidwhthomas
Copy link

There is a similar case for instagram TV, it's not matching the pattern and returning the login page, Embed v3.4

e.g https://www.instagram.com/tv/CC8AXWhgm_c/?utm_source=ig_web_copy_link

P.S awesome library, thanks

reflexxion pushed a commit to RedaktionsNetzwerk-Deutschland/Embed that referenced this issue Nov 5, 2020
reflexxion pushed a commit to RedaktionsNetzwerk-Deutschland/Embed that referenced this issue Nov 5, 2020
@Rapid0s
Copy link

Rapid0s commented Nov 5, 2020

Is it possible for Instagram and Facebook some how force the lib to use the original url and not use any redirect ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants